Getting name of sheet

J

jodleren

Hi all

I would like to get the name of the sheet in cell A1, is there a
function for that?

Can I get it like this?

Function GetPageName()
GetPageName = Worksheets(5).Name
End Function

and use it in a cell like

=GetPageName( WhatDoI_needToPutHere? )

When printing, I want all pages to be landscape - how do I do that?
And the 2 upper lines, should read:

<page name> pageno. < of pages>
Headers....

WBR
Sonnich
 
P

Per Jessen

Hi

Assuming you want to show the name of the current sheet use this:

Function GetPageName()
GetPageName = ActiveSheet.Name
End Function

=GetPageName()

To print in landscape goto File > Page Setup > Landscape

Use the header/footer option in the Page Setu Menu (other tab) to create
headers on each page.

Regards,
Per
 
J

jodleren

Hejsa
Function GetPageName()
  GetPageName = ActiveSheet.Name
End Function

But - when printing 6 pages, will they get their own name, or the
active sheets name?
Then I'll get 6 pages with the same name - not what I want
=GetPageName()

To print in landscape goto File > Page Setup > Landscape

yep, but is there an OnBeforePrint event, where I can force it?
Use the header/footer option in the Page Setu Menu (other tab) to create
headers on each page.

Can I force this too?

Med venlig hilsen
Sonnich
 
P

Per Jessen

Hej Sonnich

When you say 6 pages, is it 6 tabs or 1 sheet with data for 6 printed pages.

As the function is non-volatile it won't update as other calculations, ie
entering the formula in a cell it will display the name of the sheet where
it's entered.

Worksheets("Sheet1").PageSetup.Orientation = xlLandscape

Turn on the macro recorder, then set up the header as desired. It should
look like this:

With ActiveSheet.PageSetup
.LeftHeader = "&A"
.CenterHeader = "Page &P of &N"
End With

Med venlig hilsen

Per

"jodleren" <[email protected]> skrev i meddelelsen
Hejsa
Function GetPageName()
GetPageName = ActiveSheet.Name
End Function

But - when printing 6 pages, will they get their own name, or the
active sheets name?
Then I'll get 6 pages with the same name - not what I want
=GetPageName()

To print in landscape goto File > Page Setup > Landscape

yep, but is there an OnBeforePrint event, where I can force it?
Use the header/footer option in the Page Setu Menu (other tab) to create
headers on each page.

Can I force this too?

Med venlig hilsen
Sonnich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top