Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

Hi,

I need some help with a macro to run before save on 2 sheets, please see the
macro I have input but it is not working on save.

macro is in sheet 8

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

and macro in sheet 3

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

I need both of these macros to run when I save on the separate sheets, can
anyone help me on this matter

Kind regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default help with macro

Hi Santaviga.

A WorkbookBbeforeSave event macro must reside in the workbook's Thisworkbook
module, and there can only be one such macro in the workbook.

Therefore, cancel the two procedures
in the sheet modules and post the
following code inyo the Thisworkbook
module:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim mySheets As Sheets

Set mySheets = Me.Sheets(Array("Sheet8", "Sheet1"))

For Each SH In mySheets
SH.PageSetup.RightFooter = "Relief Shifts " _
& Format(Now, "dd-mmm-yy")
Next SH
End Sub
'<<=========


---
Regards.
Norman


"santaviga" wrote in message
...
Hi,

I need some help with a macro to run before save on 2 sheets, please see
the
macro I have input but it is not working on save.

macro is in sheet 8

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

and macro in sheet 3

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

I need both of these macros to run when I save on the separate sheets, can
anyone help me on this matter

Kind regards


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

Thanks for your response, I need the footers in both sheets to be different,
sheet 1 relief shifts and date

Sheet 8 only the date. Any ideas

"Norman Jones" wrote:

Hi Santaviga.

A WorkbookBbeforeSave event macro must reside in the workbook's Thisworkbook
module, and there can only be one such macro in the workbook.

Therefore, cancel the two procedures
in the sheet modules and post the
following code inyo the Thisworkbook
module:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim mySheets As Sheets

Set mySheets = Me.Sheets(Array("Sheet8", "Sheet1"))

For Each SH In mySheets
SH.PageSetup.RightFooter = "Relief Shifts " _
& Format(Now, "dd-mmm-yy")
Next SH
End Sub
'<<=========


---
Regards.
Norman


"santaviga" wrote in message
...
Hi,

I need some help with a macro to run before save on 2 sheets, please see
the
macro I have input but it is not working on save.

macro is in sheet 8

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

and macro in sheet 3

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

I need both of these macros to run when I save on the separate sheets, can
anyone help me on this matter

Kind regards


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

Tried the code but reporting abiguous error, I do have another before save
macro in the workbook also will this have anything to do with it?

Mark

"Norman Jones" wrote:

Hi Santaviga.

A WorkbookBbeforeSave event macro must reside in the workbook's Thisworkbook
module, and there can only be one such macro in the workbook.

Therefore, cancel the two procedures
in the sheet modules and post the
following code inyo the Thisworkbook
module:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim mySheets As Sheets

Set mySheets = Me.Sheets(Array("Sheet8", "Sheet1"))

For Each SH In mySheets
SH.PageSetup.RightFooter = "Relief Shifts " _
& Format(Now, "dd-mmm-yy")
Next SH
End Sub
'<<=========


---
Regards.
Norman


"santaviga" wrote in message
...
Hi,

I need some help with a macro to run before save on 2 sheets, please see
the
macro I have input but it is not working on save.

macro is in sheet 8

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

and macro in sheet 3

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As
Boolean)
ActiveSheet.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

I need both of these macros to run when I save on the separate sheets, can
anyone help me on this matter

Kind regards


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default help with macro

Hi Santaviga.


=============
Thanks for your response, I need the footers in both sheets to be different,
sheet 1 relief shifts and date

Sheet 8 only the date.
=============

The footers were identical because that
is what you showed, However, try:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object

With Me
Set SH = .Sheets("Sheet1") '<<==== CHANGE
Set SH2 = .Sheets("Sheet3") '<<==== CHANGE
End With

SH.PageSetup.RightFooter = _
"Relief Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE

SH2.PageSetup.RightFooter = _
"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE
End Sub
'<<=========

=============
Tried the code but reporting abiguous error, I do have another before save
macro in the workbook also will this have anything to do with it?
=============

See my comment:

A WorkbookBbeforeSave event macro must reside
in the workbook's Thisworkbook
module, and there can only be one such macro in the
workbook.


You will need to amalgamate your existing
Workbook_BeforeSave procedure with the
above code.

If you experience difficulty in amalgamating
the two procedures, post the code for each
in a response here.

Incidentally, do you have a good reason for
setting the footers before every save operation?



---
Regards.
Norman



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

Hi, I keep getting this ambigous name error with regards to private sub
workbook before save

"Norman Jones" wrote:

Hi Santaviga.


=============
Thanks for your response, I need the footers in both sheets to be different,
sheet 1 relief shifts and date

Sheet 8 only the date.
=============

The footers were identical because that
is what you showed, However, try:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object

With Me
Set SH = .Sheets("Sheet1") '<<==== CHANGE
Set SH2 = .Sheets("Sheet3") '<<==== CHANGE
End With

SH.PageSetup.RightFooter = _
"Relief Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE

SH2.PageSetup.RightFooter = _
"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE
End Sub
'<<=========

=============
Tried the code but reporting abiguous error, I do have another before save
macro in the workbook also will this have anything to do with it?
=============

See my comment:

A WorkbookBbeforeSave event macro must reside
in the workbook's Thisworkbook
module, and there can only be one such macro in the
workbook.


You will need to amalgamate your existing
Workbook_BeforeSave procedure with the
above code.

If you experience difficulty in amalgamating
the two procedures, post the code for each
in a response here.

Incidentally, do you have a good reason for
setting the footers before every save operation?



---
Regards.
Norman

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default help with macro

Hi Santaviga,

Hi, I keep getting this ambigous name error with regards to private sub
workbook before save


As previously explained, only one
Workbook_BeforeSave event procedure
may reside in the Workbook's
ThisWorkbook module.

Your error suggests that you have more
than one such procedure. In such case,
as explained, it will be necessary either to
delete one of the procedures or, more
probably, amalgamate the code to produce
a single routine.


---
Regards.
Norman
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

Here is the code I have input:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object
With Me
Set SH = .Sheets("Sheet3")
Set SH2 = .Sheets("Sheet8")
End With
SH.PageSetup.RightFooter = Format(Now, "dd-mmm-yy")
SH2.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub


"Norman Jones" wrote:

Hi Santaviga.


=============
Thanks for your response, I need the footers in both sheets to be different,
sheet 1 relief shifts and date

Sheet 8 only the date.
=============

The footers were identical because that
is what you showed, However, try:

'=========
Option Explicit

Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object

With Me
Set SH = .Sheets("Sheet1") '<<==== CHANGE
Set SH2 = .Sheets("Sheet3") '<<==== CHANGE
End With

SH.PageSetup.RightFooter = _
"Relief Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE

SH2.PageSetup.RightFooter = _
"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE
End Sub
'<<=========

=============
Tried the code but reporting abiguous error, I do have another before save
macro in the workbook also will this have anything to do with it?
=============

See my comment:

A WorkbookBbeforeSave event macro must reside
in the workbook's Thisworkbook
module, and there can only be one such macro in the
workbook.


You will need to amalgamate your existing
Workbook_BeforeSave procedure with the
above code.

If you experience difficulty in amalgamating
the two procedures, post the code for each
in a response here.

Incidentally, do you have a good reason for
setting the footers before every save operation?



---
Regards.
Norman

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default help with macro

Hi Santaviga,

Change:

"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE


to
Format(Now, "dd-mmm-yy")


---
Regards.
Norman
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help with macro

Change:

"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE


to
Format(Now, "dd-mmm-yy")


I don't think so... notice the line continuation character (the trailing
underbar character) on the preceding line... the & is there to concatenate
the output from the Format command with that preceding continued line.

Rick



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default help with macro

This has been done but still error.

"Norman Jones" wrote:

Hi Santaviga,

Change:

"Other Shifts " _
& Format(Now, "dd-mmm-yy") '<<==== CHANGE


to
Format(Now, "dd-mmm-yy")


---
Regards.
Norman

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
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 05:30 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"