Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default Using a named range in a header with VBA?

I'd like to apply a named range to headers in a file. I did a search
and found some syntax that is close, but still generating an error.
The named range is "DollarVal". The code I have is

ActiveSheet.PageSetup.RightHeader = "Total: " & Range(DollarVal)

Any thoughts? Thanks!

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default Using a named range in a header with VBA?

You need to enclose the name in quotes.

But if you want a total, shouldn't you sum it as well?

ActiveSheet.PageSetup.RightHeader = "Total: " &
Application.SUM(Range("DollarVal"))


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
ups.com...
I'd like to apply a named range to headers in a file. I did a search
and found some syntax that is close, but still generating an error.
The named range is "DollarVal". The code I have is

ActiveSheet.PageSetup.RightHeader = "Total: " & Range(DollarVal)

Any thoughts? Thanks!



  #3   Report Post  
 
Posts: n/a
Default Using a named range in a header with VBA?

Bob- Thanks for such a quick response. I still get an error:
Run-time error '1004':
Method 'Range' of object '_Global' failed

Am I missing something?

  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default Using a named range in a header with VBA?

Is it NG wrap-around?

Try

ActiveSheet.PageSetup.RightHeader = "Total: " & _
Application.SUM(Range("DollarVal"))


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
ups.com...
Bob- Thanks for such a quick response. I still get an error:
Run-time error '1004':
Method 'Range' of object '_Global' failed

Am I missing something?



  #5   Report Post  
 
Posts: n/a
Default Using a named range in a header with VBA?

It's not a word-wrap issue; I have it all on one line.

As a test I closed Excel and re-started; I created the named range and
started a new macro with only one line (the one you posted). That
generated the same error when I ran it.

I looked at the MS Knowledge Base and found an article
http://support.microsoft.com/default...b;en-us;319832
that talks about unqualified references in VB (not VBA). Could this be
a similar situation?



  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default Using a named range in a header with VBA?

It doesn't look related to me. A long-shot, but check if you have any
missing references (ToolsReferences), uncheck them if so.

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
ups.com...
It's not a word-wrap issue; I have it all on one line.

As a test I closed Excel and re-started; I created the named range and
started a new macro with only one line (the one you posted). That
generated the same error when I ran it.

I looked at the MS Knowledge Base and found an article
http://support.microsoft.com/default...b;en-us;319832
that talks about unqualified references in VB (not VBA). Could this be
a similar situation?



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
named range with filter dee Excel Worksheet Functions 3 October 17th 05 04:46 PM
Passing Excel NAMED Range to VBA BG Excel Worksheet Functions 4 July 28th 05 05:23 PM
Offset Function works in cell, not in named range DragonslayerApps Excel Worksheet Functions 0 July 25th 05 04:39 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
named range refers to: in a chart Spencer Hutton Excel Discussion (Misc queries) 1 December 14th 04 10:15 PM


All times are GMT +1. The time now is 07:08 PM.

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

About Us

"It's about Microsoft Excel"