Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
have an Excel worksheet (called MyWorksheet) where I am trying to select a
customer name and address from a list of all customers located on another worksheet (CustomerWorksheet). I am using a multicolumn listbox on a userform to select the customer data. Once selected, I want to capture the customer data in a multicolumn array and then write the customer data to a worksheet range in MyWorksheet. The code I have written seems to be able to capture the selected customer data (all columns) in an array but it will not write the data to the range in the MyWorksheet. Any help would be greatly appreciated. Thanks Private Sub cmdOkay_Click() Dim i As Long, j As Long Dim lRows As Long, lCols As Long Dim CustArray() As Variant lRows = ListBox1.ListCount - 1 lCols = ListBox1.ColumnCount - 1 'Fill array with data of selected customer For i = 1 To lRows If ListBox1.Selected(i) Then For j = 0 To lCols ReDim CustArray(lRows, lCols) CustArray(1, j) = ListBox1.List(i, j) Next j End If Next i Unload userform1 'Write array data to range on worksheet With Worksheets("MyWorksheet").Range("CustomerData") ..ClearContents ..Value = CustArray End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fill a multicolumn listbox with data from a range in another works | Excel Programming | |||
Writing array data to range object always writes 0's on worksheet | Excel Programming | |||
Writing a range to an array... | Excel Programming | |||
Q: Best way to take data from VBA into graphs without writing data to worksheets? (Can a named range refer to an array in memory only?) | Excel Programming | |||
Writing Range to Array | Excel Programming |