View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Find Column Letter - When column header is found

Click on AD65536 on the sheet and then pull down:

Insert Name Define kenny

So now kenny is the Name associated with cell AD65536

If you add or remove columns, the Name will adjust. Then in VBA:

Sub sistence()
lastRow = Range("kenny").End(xlUp).Row
Range("A3").AutoFill Destination:=Range("A3:A" & lastRow)
End Sub

Always consider using a Defined Name if you have to refer to a point of the
worksheet that has to move.
--
Gary''s Student - gsnu200800


"Kenny" wrote:

I have the following code to fill range based on the first cell in that
range. However, I add and remove colums frequentley, this causes me to
constantley change the column references in the below code. How can the code
follow the column changes. I can only think that I would have to search the
header row (2) for the specific text in that header to identify the column
for the code. Not sure at all about how to go about this. Please help. Thanks!


lastRow = Range("AD65536").End(xlUp).Row
Range("A3").AutoFill Destination:=Range("A3:A" & lastRow)