Worksheet name in footer

G

Guest

Hi all,

Relatively simple one I hope. Trying to insert a footer that automatically
updates to the name of the current worksheet. I've got &[Path] to show the
directory, &[File] to show the file name, but what would be the short way to
get the worksheet name in the footer? &[???]

Thanks in advance,

Mike
 
B

Bob Phillips

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
.PageSetup.LeftFooter = .Name
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

Hi Bob,

Thanks for that, but unfortunately not exactly what I'm after - sorry,
should have been clearer!!

I've got a macro that inserts the path, worksheet, filename. However, I've
found that the problem with this is that once it's in, it doesn't update if I
save the book as a new book or update the worksheet name. I.e. it takes a
snapshot of what the file is and inserts it as a footer, but when I save to a
new month it doesn't update unless I run the macro again.

I have noticed though that the &[path] and &[File] methods do update when
saved as a new workbook so was hoping that there would be a similar way of
adding the worksheet name.

Any thoughts?

Thanks,

Mike

Bob Phillips said:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
.PageSetup.LeftFooter = .Name
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

mike_vr said:
Hi all,

Relatively simple one I hope. Trying to insert a footer that automatically
updates to the name of the current worksheet. I've got &[Path] to show the
directory, &[File] to show the file name, but what would be the short way
to
get the worksheet name in the footer? &[???]

Thanks in advance,

Mike
 
N

Niek Otten

&[Tab]

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

| Hi Bob,
|
| Thanks for that, but unfortunately not exactly what I'm after - sorry,
| should have been clearer!!
|
| I've got a macro that inserts the path, worksheet, filename. However, I've
| found that the problem with this is that once it's in, it doesn't update if I
| save the book as a new book or update the worksheet name. I.e. it takes a
| snapshot of what the file is and inserts it as a footer, but when I save to a
| new month it doesn't update unless I run the macro again.
|
| I have noticed though that the &[path] and &[File] methods do update when
| saved as a new workbook so was hoping that there would be a similar way of
| adding the worksheet name.
|
| Any thoughts?
|
| Thanks,
|
| Mike
|
| "Bob Phillips" wrote:
|
| > Private Sub Workbook_BeforePrint(Cancel As Boolean)
| > With ActiveSheet
| > .PageSetup.LeftFooter = .Name
| > End With
| > End Sub
| >
| > 'This is workbook event code.
| > 'To input this code, right click on the Excel icon on the worksheet
| > '(or next to the File menu if you maximise your workbooks),
| > 'select View Code from the menu, and paste the code
| >
| >
| > --
| > HTH
| >
| > Bob
| >
| > (there's no email, no snail mail, but somewhere should be gmail in my addy)
| >
| > | > > Hi all,
| > >
| > > Relatively simple one I hope. Trying to insert a footer that automatically
| > > updates to the name of the current worksheet. I've got &[Path] to show the
| > > directory, &[File] to show the file name, but what would be the short way
| > > to
| > > get the worksheet name in the footer? &[???]
| > >
| > > Thanks in advance,
| > >
| > > Mike
| >
| >
| >
 

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