LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Writing multicolumn array data to a worksheet range

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill a multicolumn listbox with data from a range in another works Dale Fye Excel Programming 1 October 12th 07 06:58 PM
Writing array data to range object always writes 0's on worksheet eholz1 Excel Programming 5 September 22nd 07 03:54 AM
Writing a range to an array... Alex Excel Programming 2 December 29th 05 01:59 PM
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?) KR Excel Programming 2 December 16th 04 11:12 PM
Writing Range to Array Marston Excel Programming 3 August 9th 04 09:11 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"