ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code to update a macro (https://www.excelbanter.com/excel-programming/301566-code-update-macro.html)

Paul

code to update a macro
 


I have written/recorded a little macro that removes an old
version of a worksheet and replaces it with the latest
version.I now wish to replace a old macro with a newer
version too.Can you give me the code that would transfer a
module from a new workbook(jul021) to the "old"
workbook,which happens to be called "mylinkname"
Sub update()
Application.DisplayAlerts = False
'Workbooks.Add Template:="\\w2k107132\Brendons
Docs\Templates\jul02.xlt"
Windows("jul021").Visible = False
Sheets("Cover").Select
mylinkname = Range("B6")
Sheets("Program").Select
Sheets("Program").Delete
Windows("jul021").Visible = True
Sheets("Program").Select
Sheets("Program").Copy Befo=Workbooks(mylinkname
& ".xls").Sheets(2)
ActiveWorkbook.ChangeLink Name:="jul021",
NewName:=mylinkname & ".xls", Type:= _
xlExcelLinks
Windows("jul021").Visible = False
Application.DisplayAlerts = True

End Sub


Tom Ogilvy

code to update a macro
 
Chip Pearson's page on programming in the VBE:
http://www.cpearson.com/excel/vbe.htm

should get you started.

--
regards,
Tom Ogilvy

"Paul" wrote in message
...


I have written/recorded a little macro that removes an old
version of a worksheet and replaces it with the latest
version.I now wish to replace a old macro with a newer
version too.Can you give me the code that would transfer a
module from a new workbook(jul021) to the "old"
workbook,which happens to be called "mylinkname"
Sub update()
Application.DisplayAlerts = False
'Workbooks.Add Template:="\\w2k107132\Brendons
Docs\Templates\jul02.xlt"
Windows("jul021").Visible = False
Sheets("Cover").Select
mylinkname = Range("B6")
Sheets("Program").Select
Sheets("Program").Delete
Windows("jul021").Visible = True
Sheets("Program").Select
Sheets("Program").Copy Befo=Workbooks(mylinkname
& ".xls").Sheets(2)
ActiveWorkbook.ChangeLink Name:="jul021",
NewName:=mylinkname & ".xls", Type:= _
xlExcelLinks
Windows("jul021").Visible = False
Application.DisplayAlerts = True

End Sub





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

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