Reputation: 151
I'm new programming at vba and I can't understand what's the difference between an actived cell and a selected cell.
I'm making a very simple example I found on internet about press a button and add the values of certain lines.
This is my example:
When I press the button that says "Rellenar" I want the information about countries goes to dropdown menu.
I made this:
Private Sub CommandButton4_Click()
Range("k6").Activate
Do While Not IsEmpty(ActiveCell)
micombo.AddItem ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
Where "k6" is the 1st cell where you can find information, but I tried to change the activate value to select value and the programm works exactly the same with both.
Can someone explain me the difference between both one?
Upvotes: 1
Views: 1914
Reputation: 268
From my understanding an Active cell is the cell the user is currently on. E.G the highlighted cell if you are in a spreadsheet.
A Selected cell is a cell that has been clicked. You can have more than one selected cell. (Usually by holding down CTRL
and selecting multiple cells) However the only active cell is the one the user is currently on.
Another example for this is when you are selecting multiple images on your computer. If you click one then that's your active cell. Whereas if you click multiple then the clicked cells are "Selected" but only your most recent click is an active cell.
Upvotes: 2