LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Creating a Dynamic Named Range Using Sheet Name and Column Header

Dim sName As String

sName = Cells(1, ActiveCell.Column).Value
ThisWorkbook.Names.Add Name:=sName & "_Sheet1", _
RefersTo:="=OFFSET(" & sName & "1!" & Cells(2, _
ActiveCell.Column).Address & _
",1,0,COUNTA(" & sName & "!" & _
ActiveCell.EntireColumn.Address & ")-1,1)"

--
Regards,
Tom Ogilvy


"burl_rfc_h" wrote in message
oups.com...
Bob,

I tried your solution, I think it's really close with a few tweaks
(sorry)....

Firstly, ThisWorkbook.Names.Add Name:=sName, _
how can I get it to include the sheet name for example suppose A2 has
Date Machined as the column header and the sheet name is Sheet1
then the range name would be Date_Machined_Sheet1
as a suggestion, do you think it would be best to set the worksheet
name to a variable, then call this out with sName.

Secondly, when I run the macro as written it includes the quotation
marks around the formula
="OFFSET(Sheet1!$A$2,1,0,COUNTA(Sheet1!$A:$A)-1,1)"
only after removing the quoation marks does the dynmanic range work.



 
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
Creating dynamic ranges which are named. U0107 Excel Worksheet Functions 1 January 5th 10 11:46 PM
Named Range in Customer Header Rebecca_SUNY Excel Discussion (Misc queries) 1 April 13th 09 10:37 PM
Multi-Column Dynamic Named Range...Is there an easier way? Ken Johnson Excel Worksheet Functions 6 April 23rd 06 01:54 AM
Using a named range in a header with VBA? [email protected] Excel Discussion (Misc queries) 5 October 27th 05 10:52 AM
Named Range in Center Header Joel Mills Excel Programming 6 January 5th 05 08:03 PM


All times are GMT +1. The time now is 04:52 PM.

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"