Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Column Letter - When column header is found

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find column letter Stuart WJG[_2_] Excel Discussion (Misc queries) 13 August 29th 08 11:27 PM
Column Header - Convert a Number to a letter stickandrock Excel Discussion (Misc queries) 1 June 9th 08 07:54 PM
Column Header is not in Letter jhunjayme Excel Discussion (Misc queries) 1 March 27th 08 10:54 AM
How to find a row since I found a value in a column? see example [email protected] Excel Worksheet Functions 1 April 25th 06 05:45 PM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM


All times are GMT +1. The time now is 12:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"