Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying a listbox to a sheet

Status
Not open for further replies.

Butane

Technical User
Oct 20, 2001
8
0
0
GB
Would it possible to copy the contents of a listbox into the column of a spread sheet? When i try it only copies the selected item not all the values. Im new to VBA and this is for a school project. If you can help me then thanks.
 
For x = 1 To ListBox1.ListCount
Range("A" & LTrim(Str(x))).Value = ListBox1.List(x - 1)
Next x

-vbMax
 
If it's for a class, then I think LTrim would be a little beyond the scope. Besides, the
Code:
Offset
property would work just as well.
Code:
For x = 0 To ListBox.ListCount - 1
   'Offset(row, column)
   Range("A1").Offset(x, 0).Value = ListBox1.List(x)
Next x
Both bits of code do the same thing. Just a matter of choice, really. ----------------------------------------
If you are reading this, then you have read too far... :p

lightwarrior@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top