+ Reply to Thread
Results 1 to 6 of 6

Using a named range in a header with VBA?

  1. #1

    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. #2
    Bob Phillips
    Guest

    Re: 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)


    <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3

    Re: 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. #4
    Bob Phillips
    Guest

    Re: 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)


    <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5

    Re: 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. #6
    Bob Phillips
    Guest

    Re: 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 (Tools>References), uncheck them if so.

    --

    HTH

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


    <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1