ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Modifing a recorded macro. (https://www.excelbanter.com/excel-programming/369328-modifing-recorded-macro.html)

Duane Reynolds

Modifing a recorded macro.
 
I would like to use this macro on 8-10 workbooks.

Range("B3:P357").Select
Selection.Copy
ChDir "M:\"
Workbooks.Open Filename:="M:\Expired Template.xlt", Editable:=True
Range("E4").Select
ActiveSheet.Paste
Range("B4").Select
Application.CutCopyMode = False
ChDir "M:\North"
Range("F4").Select
ActiveCell.FormulaR1C1 = "ALLYN"
ActiveWorkbook.SaveAs Filename:="M:\North\ALLYN.xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

I want to save the workbooks using the name in cell f4. the recorded macro
has hard coded the name in first workbook uses it to name the other workbooks
Thanks for the help in advance

--
Duane Reynolds
XP Associate Expert

Franz Verga

Modifing a recorded macro.
 
"Duane Reynolds" ha scritto nel
messaggio ...
I would like to use this macro on 8-10 workbooks.

Range("B3:P357").Select
Selection.Copy
ChDir "M:\"
Workbooks.Open Filename:="M:\Expired Template.xlt", Editable:=True
Range("E4").Select
ActiveSheet.Paste
Range("B4").Select
Application.CutCopyMode = False
ChDir "M:\North"
Range("F4").Select
ActiveCell.FormulaR1C1 = "ALLYN"
ActiveWorkbook.SaveAs Filename:="M:\North\ALLYN.xls", FileFormat:=xlNormal
_
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

I want to save the workbooks using the name in cell f4. the recorded macro
has hard coded the name in first workbook uses it to name the other
workbooks
Thanks for the help in advance


Hi Duane,
try with this:

Sub Test()
Dim filen As String

Range("B3:P357").Copy
Workbooks.Open Filename:="M:\Expired Template.xlt", Editable:=True
Range("E4").Select
ActiveSheet.Paste
Application.CutCopyMode = False
filen = "M:\North\" & Range("F4").Value & ".xls"
ActiveCell.FormulaR1C1 = "ALLYN"
ActiveWorkbook.SaveAs filen, FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy




All times are GMT +1. The time now is 10:05 PM.

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