View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default list box columns not transferring

Uh, 2 loops?

For x = 0 To .ListCount - 1
If .Selected(x) = True Then
For j = 1 To .ColumnCount
Sheets("sheet2").Cells(i, j).Value = .List(x, j - 1)
Next j
i = i + 1
End If
Next x


--

HTH

RP
(remove nothere from the email address if mailing direct)


"pcscsr" wrote in message
...

I have a multi column (4) list box with the following columns:

Botanical Name Common Name size price

the following code transferrs the columns from the list box to a
separate worksheet

Private Sub CommandButton1_Click()
Dim i As Integer, x As Integer
i = 2
Sheets("sheet2").Range("a:d").EntireColumn.ClearCo ntents
With ListBox1
For x = 0 To .ListCount - 1
If .Selected(x) = True Then
Sheets("sheet2").Cells(i, 1) = .List(x, 0)
i = i + 1
End If
Next x
End With
UserForm1.Hide
End Sub


The code works however it only transferrs the 1st column "Botanical
Name" and not the other three.

How can I modify this so that it also transfers the other three
columns. I am on a deadline for work and this is the only thing that
is holding me up from completing my project.


--
pcscsr
------------------------------------------------------------------------
pcscsr's Profile:

http://www.excelforum.com/member.php...o&userid=12006
View this thread: http://www.excelforum.com/showthread...hreadid=273998