Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I didn't suggest using the last column for anything.
The code searched for text in a header row. Kenny wrote: Thanks all of you for replying. The last column is not the problem. Lets say the named range "Account" is cell A3; how can I create an auto fill based on that. For example: tracker.Range("Account").AutoFill Destination:=Range("Account:Account" & lastRow) Of course this does not work. But basically I want this formula to equal tracker.Range("A3").AutoFill Destination:=Range("A3:A" & lastRow) But to be based on the named range so no matter when I add a column it will follow this column based on the name ranged Thanks "Dave Peterson" wrote: dim wks as worksheet dim LastRow as long dim FoundCell as range set wks = worksheets("somesheetnamehere") with wks with .rows(1) set foundcellvar1 = .Cells.Find(What:="YourHeaderString", _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) end with if foundcell is nothing then msgbox "header wasn't found, quitting!" exit sub end if lastrow = .cells(.rows.count,foundcell.column).end(xlup).row ... (Untested, uncompiled.) 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) -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
find column letter | Excel Discussion (Misc queries) | |||
Column Header - Convert a Number to a letter | Excel Discussion (Misc queries) | |||
Column Header is not in Letter | Excel Discussion (Misc queries) | |||
How to find a row since I found a value in a column? see example | Excel Worksheet Functions | |||
column header changed from letter to number, how return to letter | Excel Discussion (Misc queries) |