Reputation: 1
I am trying to add names to the combo Box. I want to see the list of recently entered values first. For example Names John Sam Smith Will
I want to see the list in combo Box drop down as Will Smith Sam John
I tried using range function to set a range and then traverse the cells in the range and adding them to the comboBox.
Function Rangeform() Set Rangeform = ActiveSheet.[a1:a50000] End Function
For each cell in Rangeform ComboBox8.AddItem cell Next
Is there a way to set the range from last used row to the first and then looping backwards?
Upvotes: 0
Views: 1887
Reputation: 35853
Try this one:
Dim lastrow As Long
Dim i As Long
'change Sheet1 to suit
With ThisWorkbook.Worksheets("Sheet1")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
'backward loop
For i = lastrow To 1 Step -1
ComboBox8.AddItem .Range("A" & i)
Next i
End With
Upvotes: 0