In my excel, from range A41 to M41 down, i will have data. In my listbox i want to see all data that i will have, not just to row 70 (as my code is). I know i have to use xlUP, but i don't know how. I i will have 500 rows down starting at A41:M41, i have to see them all. Here is my code down to row 70 (specific range):
Private Sub UserForm_Activate()
Dim lb As msforms.ListBox
Dim rcArray() As Variant
Dim lrw As Long, lcol As Long
Dim rngTarget As Range
Set rngTarget = Worksheets("Sheet1").Range("A41:M70")
ReDim Preserve rcArray(1 To rngTarget.Rows.Count, 1 To rngTarget.Columns.Count)
With rngTarget
For lcol = 1 To .Columns.Count
For lrw = 1 To .Rows.Count
rcArray(lrw, lcol) = rngTarget.Cells(lrw, lcol)
Next lrw
Next lcol
End With
Set lb = Me.ListBox1
With lb
.ColumnCount = 13
.ColumnWidths = "50;80;100"
.List = rcArray
End With