Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
list box columns not transferring
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 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 "Botanica Name" and not the other three. How can I modify this so that it also transfers the other thre columns. I am on a deadline for work and this is the only thing tha is holding me up from completing my project -- pcscs ----------------------------------------------------------------------- pcscsr's Profile: http://www.excelforum.com/member.php...fo&userid=1200 View this thread: http://www.excelforum.com/showthread.php?threadid=27399 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data validated list not transferring to Word - excel sheet | Excel Discussion (Misc queries) | |||
Help with transferring data in one column to multiple columns. | New Users to Excel | |||
Transferring from both columns of a listbox to another | Excel Discussion (Misc queries) | |||
Lookup of Cells and transferring them to make a list | Excel Worksheet Functions | |||
List box with 2 columns | Excel Programming |