I fail at searching, and thank you for your help in advance.
I have a worksheet, Sheet1, on which I have a list of cars in column A. It will always be in column A, and there will be a header "Cars" in cell A1. How do I select the cells and name the range?
I have this macro I recorded, but I can't figure out how to Name the Range if the number of cars in the list changes. The part I don't know how to work around is the reference to "R2C1:R39C1". That might change depending on how long the list is.
I feel so dumb here. Thank you for your time.
Follow up question would be, how would I do the same if the list of Cars was a table? Or would that be a better solution overall? What I'm going to end up doing is looping through the list. Would it be easier to use that list of Cars in VBA and loop through each that way?
Thanks!!
Matt
I have a worksheet, Sheet1, on which I have a list of cars in column A. It will always be in column A, and there will be a header "Cars" in cell A1. How do I select the cells and name the range?
I have this macro I recorded, but I can't figure out how to Name the Range if the number of cars in the list changes. The part I don't know how to work around is the reference to "R2C1:R39C1". That might change depending on how long the list is.
Code:
Sheets("Sheet1").Select
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="CarsList", RefersToR1C1:= _
"=Sheet1!R2C1:R39C1"
Range("A2").Select
I feel so dumb here. Thank you for your time.
Follow up question would be, how would I do the same if the list of Cars was a table? Or would that be a better solution overall? What I'm going to end up doing is looping through the list. Would it be easier to use that list of Cars in VBA and loop through each that way?
Thanks!!
Matt