Consulting

Results 1 to 5 of 5

Thread: Solved: Help with macro

  1. #1

    Solved: Help with macro

    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    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.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    XLD-thanks very much!
    Problem is solved!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •