View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Eric White[_2_] Eric White[_2_] is offline
external usenet poster
 
Posts: 45
Default Hidden characters

I think you may be confusing the special codes that Excel uses for inserting
data (page no., total pages, date, etc.) into headers/footer with the codes
Excel VBA uses.

If you look in the page setup for an Excel worksheet, the page number code
shows as "[&Page]". However, the special code that you must use in Excel VBA
is "&P" (note no space between & and P). If I understand what you're trying
to do, you want to put "Page x of y" in your right header. In Excel VBA, you
would write the string "Page &P of &N". The "&" tells Excel the next
character is a special code.

For more information, search for "Formatting Codes for Headers and Footers"
in the VBA help files.

"Rookie 1st class" wrote:

Two formulas appear the same:
ActiveSheet.PageSetup.RightHeader = _
"&""Arial Narrow,Regular""&8Page &P of " & N

The one recorded with the Macro Recorder has the "N" encased in [] (didn't
work).
What are these "[]", how, where, and when should are they used?
Thanks
Lou