Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am struggling with how to paste only the last two columns of a three
column listbox (Listbox1) into a named range ("DataRange") on a worksheet ("Sheet1"). The number of rows and columns are not dynamic. Listbox1 always has 3 columns with 18 rows and DataRange always has 2 columns and 18 rows. I want to paste the contents of columns 2 and 3 from ListBox1 into DataRange. A simple task but I cannot get the syntax correct. GH |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
GH
Try something like this Private Sub CommandButton1_Click() Dim rData As Range Dim i As Long, j As Long Set rData = Sheet1.Range("DataRange") For i = 0 To Me.ListBox1.ListCount - 1 For j = 1 To 2 'columns start at zero, this is cols 2 and 3 rData.Cells(i + 1, j).Value = Me.ListBox1.List(i, j) Next j Next i End Sub -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com GH wrote: I am struggling with how to paste only the last two columns of a three column listbox (Listbox1) into a named range ("DataRange") on a worksheet ("Sheet1"). The number of rows and columns are not dynamic. Listbox1 always has 3 columns with 18 rows and DataRange always has 2 columns and 18 rows. I want to paste the contents of columns 2 and 3 from ListBox1 into DataRange. A simple task but I cannot get the syntax correct. GH |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you. I feel silly.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Paste to next empty cell in named range of cells | Excel Discussion (Misc queries) | |||
Paste a named range to another range in Excel | Excel Discussion (Misc queries) | |||
Q: find range, listbox - format and fit columns | Excel Programming | |||
listbox not dsplaying all records in a named range | Excel Programming | |||
Transfer multiple columns items form listbox to range | Excel Programming |