CtrlAltDel2X
New Member
- Joined
- Aug 26, 2015
- Messages
- 7
I have two spreadsheet columns of non-contiguous data.
Column B is the "key" column. VBA rng1 consists of cells where there is text in Column B cells.
Trying to create VBA rng2 which consists of rng1 cells and the adjacent Column A cells.
Next is to then populate two array columns with each row of rng2. The two array columns will eventually fill a UserForm ListBox without blank lines in the second column of the ListBox.
ISSUE: Only the first row of rng2 is populating the listbox.
Thanks for tips!
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim Arr() As Variant
Dim rng1 As Range
Dim rng2 As Range
Dim LastRow As Integer
Dim R As Long
Dim C As Long
Set ws = Worksheets("test")
LastRow = ws.UsedRange.Rows.Count
Set rng1 = ws.Range("B1:B" & LastRow).SpecialCells(xlCellTypeConstants, xlTextValues)
Set rng2 = Union(rng1.Offset(0, -1), rng1)
Arr = rng2
With ListBox1
.List = Arr
End With
End Sub
Column B is the "key" column. VBA rng1 consists of cells where there is text in Column B cells.
Trying to create VBA rng2 which consists of rng1 cells and the adjacent Column A cells.
Next is to then populate two array columns with each row of rng2. The two array columns will eventually fill a UserForm ListBox without blank lines in the second column of the ListBox.
ISSUE: Only the first row of rng2 is populating the listbox.
Thanks for tips!
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim Arr() As Variant
Dim rng1 As Range
Dim rng2 As Range
Dim LastRow As Integer
Dim R As Long
Dim C As Long
Set ws = Worksheets("test")
LastRow = ws.UsedRange.Rows.Count
Set rng1 = ws.Range("B1:B" & LastRow).SpecialCells(xlCellTypeConstants, xlTextValues)
Set rng2 = Union(rng1.Offset(0, -1), rng1)
Arr = rng2
With ListBox1
.List = Arr
End With
End Sub
Last edited: