PDA

View Full Version : Solved: Help with macro



Alexon2008
05-28-2008, 02:15 PM
I have a listbox which is embeded (not forms listbox!) on sheet 1. Listbox contains numbers. I have also macro called "Print" which I recorded.

I want macro which copy first item from listbox and paste item in cell A2 and then run macro "print". Then copy second item from listbox to cell A2 and run macro "print". That should be done as long as there is items in listbox.

Bob Phillips
05-28-2008, 02:48 PM
Dim i As Long

With ActiveSheet.OLEObjects("ListBox1")

For i = 0 To .Object.ListCount - 1

ActiveSheet.Range("A2").Value = .Object.List(i, 0)
Call PrintMacro
Next i
End With

Alexon2008
05-28-2008, 03:02 PM
xld-It works-thank you very much.
one more question
What to change in macro if numbers are in column C starting with c3m and not in listbox.

Bob Phillips
05-28-2008, 03:14 PM
Dim cell As Range

With ActiveSheet

For Each cell In .Range("C3",Range("C3").End(xlDown))

ActiveSheet.Range("A2").Value = cell.Value
Call PrintMacro
Next cell
End With

Alexon2008
05-28-2008, 03:17 PM
XLD-thanks very much!
Problem is solved!