Hi
I've got a macro which imports data with multiple Brands into a file.
Is there code that exists to list the names of populated cells in a Sheet?
So if the brand names Coke, Pepsi and Sprite existed in cells A1, A2, and A3, as below, is there a way that you can get the code to list the cell names in a message box? NB the code would ideally go to the end of the column, so if, on the next iteration, there was a fourth brand eg Dr Pepper, then the code would list all brands, including Dr Pepper.
And equally, if there were only two brands, then it would just list Coke and Pepsi, or whatever the two brands were in the list....
The code for a message box is easy (MsgBox: "You've imported ..., ..., and .... into the file"). But I'm not sure how to do the first bit?
I guess I would need to use something like this, but I'm not sure how to modify it to read the names of cells A1, A2, A3, etc....
Your help would be appreciated.
I've got a macro which imports data with multiple Brands into a file.
Is there code that exists to list the names of populated cells in a Sheet?
So if the brand names Coke, Pepsi and Sprite existed in cells A1, A2, and A3, as below, is there a way that you can get the code to list the cell names in a message box? NB the code would ideally go to the end of the column, so if, on the next iteration, there was a fourth brand eg Dr Pepper, then the code would list all brands, including Dr Pepper.
And equally, if there were only two brands, then it would just list Coke and Pepsi, or whatever the two brands were in the list....
Coke |
Pepsi |
Sprite |
I guess I would need to use something like this, but I'm not sure how to modify it to read the names of cells A1, A2, A3, etc....
Your help would be appreciated.
VBA Code:
Sub Test2()
' Select cell A1, *first line of data*.
Range("A1").Select
' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
' Insert your code here.
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
End Sub