Welcome. I am trying to fill a combobox with the values of two different columns. The following code does this, but I am having difficulty modifying it.
I want to fetch all column values up to the last row without selecting the last cell within the code, while ignoring the Empty cells if they are present in any column.
I want to fetch all column values up to the last row without selecting the last cell within the code, while ignoring the Empty cells if they are present in any column.
VBA Code:
Private Sub UserForm_Initialize()
Set f = Sheets("Sheet1")
'Lastrow = f.Cells(f.Rows.Count, 1).End(xlUp).Row
a = Application.Transpose(f.[a1:a10])
b = Application.Transpose(f.[D1:D10])
c = Split(Join(a, ",") & "," & Join(b, ","), ",")
Me.ComboBox1.List = c
End Sub