Hi,
I'd like to transfer columns 1, 2 and 4 from a userform listbox to columns A, B and C of a worksheet, but find this to be beyond my reach. Can anyone help me with a code that does this? Thanks a lot.
Hi,
I'd like to transfer columns 1, 2 and 4 from a userform listbox to columns A, B and C of a worksheet, but find this to be beyond my reach. Can anyone help me with a code that does this? Thanks a lot.
Last edited by WCJanssen; 04-30-2011 at 08:06 AM. Reason: solved; changed prefix
Hello WCJanssen,
The macro below will copy the columns of the List Box to the worksheet starting at cell "A1". Change the list box name if you need to and the starting cell in column "A" as well.
![]()
Sub CopyListData() Dim Data() As Variant Dim I As Long ReDim Data(ListBox1.ListCount - 1, 2) For I = 0 To UBound(Data) Data(I, 0) = ListBox1.List(I, 0) Data(I, 1) = ListBox1.List(I, 1) Data(I, 2) = ListBox1.List(I, 3) Next I Range("A1").Resize(I, 3) = Data End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
![]()
Private Sub CommandButton1_Click() With ThisWorkbook.Sheets("Sheet1") For i = 0 To Me.ListBox1.ListCount - 1 .Cells(i + 1, "A").Value = Me.ListBox1.Column(0, i) .Cells(i + 1, "B").Value = Me.ListBox1.Column(1, i) .Cells(i + 1, "C").Value = Me.ListBox1.Column(3, i) Next i End With End Sub
thanks! that did the trick.
or
![]()
sub snb() Sheets(1).Cells(1).Resize(ListBox1.ListCount, UBound(ListBox1.List, 2) + 1) = ListBox1.List Sheets(1).columns(3).delete End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks