ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   1 button for 2 macros (https://www.excelbanter.com/excel-discussion-misc-queries/31519-1-button-2-macros.html)

lunker55

1 button for 2 macros
 
I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub




Pank

Lunker55,

Amalgamate you macros.

Assume that the first macro is called Save and the second macro is called
clearform. Assume that you want to run CLEARFORM after SAVE do the following:-

Just before the END SUB in SAVE type CLEARFORM

HTH

Pank

"lunker55" wrote:

I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub





Norman Jones

Hi Joe,

Try assigning the following macro to your button:

SubRunBoth()
Call clearform
Call SaveAsCellString
End Sub

This assumes that you want to the clearform macro to be run first. If this
assumption is wrong, reverse the sequence of the two Call statements.

---
Regards,
Norman



"lunker55" wrote in message
...
I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub






Phil Wales

Easy way to do it is record a 3rd macro while clicking macro 1 & macro 2 and
call it maro 3



"lunker55" wrote:

I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub





lunker55

Thank you both!

Joe

"lunker55" wrote in message
...
I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub






Don Guillett

this should do it. I do NOT recommend saying as 97/95. Just save as an excel
file.

Sub SaveAsCellString()
Range("A16:C28,e8").ClearContents
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5")
End Sub


--
Don Guillett
SalesAid Software

"lunker55" wrote in message
...
I have two macros. I would like to press 1 macro button that will do both
macros.
Is there a way to do this?
Macros are below,
Joe

Sub SaveAsCellString()
ActiveWorkbook.SaveAs Filename:= _
"C:\shipway\invoices\" & Range("E5").Formula,
FileFormat:=xlExcel9795, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Sub clearform()
'
' clearform Macro
' Macro recorded 20/06/2005 by Joe Clarkson
'

'
Range("A16:C28").Select
Selection.ClearContents
Range("E8").Select
Selection.ClearContents
End Sub







All times are GMT +1. The time now is 04:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com