Evening all. 365 on Windows. I visit occasionally when puzzling with my VBA addiction. Need help finishing code to populate listbox2 in userform1. If column A contains text "DC", additem from column M data. Column M is dynamic. From older posts searched I have a start...
...which works fine for ALL of column M, but of course I only want column M if column A contains "DC". I was tinkering with something like:
Seemed like it would be easy to get there, but after 2 days of trying different guesses, I fear I'm just not getting there without help. Thank you to any takers.
VBA Code:
Private Sub Userform_Initialize()
Dim rng As Range
With Workbooks("RoomCardList.xlsx").Sheets("Export Here")
Set rng = .Range(.Cells(1, 14), .Cells(.Rows.Count, 14).End(xlUp))
End With
With Me.ListBox2
.RowSource = rng.Address
End With
End Sub
...which works fine for ALL of column M, but of course I only want column M if column A contains "DC". I was tinkering with something like:
Code:
'rowsCount = ws.Cells(ws.Rows.Count, 14).End(xlUp).Row
'For i = 0 To rowsCount
' If ws.Cells(i, 1).Value = "DC" Then
' ListBox2.AddItem (ws.Cells(i, 14).Value)
' End If
'Next i
Seemed like it would be easy to get there, but after 2 days of trying different guesses, I fear I'm just not getting there without help. Thank you to any takers.