Shiraj_Hoque
12-01-2010, 01:05 PM
Hi Newbie here,
I have a code that takes information from one ListBox to another. Now I need the selected information to go from the second listbox to a spreadsheet.
I can get the information on the spreadsheet but its not dynamic enough. I think I need to incorporate a COUNTA with the Offset but dont know how to in VBA.
can someone guide me in the right direction and offer notes to explain. I'm keen to learn so would be great.
Private Sub CommandButton3_Save_to_Site_Specific_Lookups_Click()
Dim C As Integer, R As Integer
Dim RefCell As Range
Set RefCell = Worksheets("KB Wide Lookup").Range("D2")
With UserForms(0)
For R = 0 To ListBox4_Site_Specific.ListCount - 1
For C = 0 To ListBox4_Site_Specific.ColumnCount - 1
RefCell.Offset(R, C).Value = ListBox4_Site_Specific.List(R, C)
Next C
Next R
End With
End Sub
EDIT: please make sure you wrap your code in code tags using the VBA button
by Simon Lloyd
I have a code that takes information from one ListBox to another. Now I need the selected information to go from the second listbox to a spreadsheet.
I can get the information on the spreadsheet but its not dynamic enough. I think I need to incorporate a COUNTA with the Offset but dont know how to in VBA.
can someone guide me in the right direction and offer notes to explain. I'm keen to learn so would be great.
Private Sub CommandButton3_Save_to_Site_Specific_Lookups_Click()
Dim C As Integer, R As Integer
Dim RefCell As Range
Set RefCell = Worksheets("KB Wide Lookup").Range("D2")
With UserForms(0)
For R = 0 To ListBox4_Site_Specific.ListCount - 1
For C = 0 To ListBox4_Site_Specific.ColumnCount - 1
RefCell.Offset(R, C).Value = ListBox4_Site_Specific.List(R, C)
Next C
Next R
End With
End Sub
EDIT: please make sure you wrap your code in code tags using the VBA button
by Simon Lloyd