ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro broken with workbook name change (https://www.excelbanter.com/excel-discussion-misc-queries/69176-macro-broken-workbook-name-change.html)

Annabelle

Macro broken with workbook name change
 
I've created a macro that allows the end user to roll-up individual
worksheets into a Master worksheet within the same workbook, executing
three other macros. This works great until the file name is changed
(reflecting the date of last change), then the receive the error below.
The working file name is Project Tracking Report - 060127.xls and all
of the macros are contained within this workbook becauses the three end
users access from a shared directory.

ASSISTANCE REQUEST
This problem occurs when the file name is changed. Is there a way to
update the code so it reflects the current workbook name?

ERROR:
Run-time error '1004':
Select method of Range class failed


MACRO
Sub MasterPTR2()
'
' MasterPTR2 Macro
' Macro recorded 1/30/2006 by B. Ann Bolland
'

'
Rows("5:800").Select
Selection.ClearContents
Range("A5").Select
Application.Run "'Project Tracking Report - 060127.xls'!Test4"
Application.Run "'Project Tracking Report -
060127.xls'!Master_Cleanup"
Application.CutCopyMode = False
Application.Run "'Project Tracking Report -
060127.xls'!Master_Cleanup2"
End Sub


Dave Peterson

Macro broken with workbook name change
 
This is just one single workbook?

If yes, then just call your other procedures:

Call Test4
(instead of application.run....)


Annabelle wrote:

I've created a macro that allows the end user to roll-up individual
worksheets into a Master worksheet within the same workbook, executing
three other macros. This works great until the file name is changed
(reflecting the date of last change), then the receive the error below.
The working file name is Project Tracking Report - 060127.xls and all
of the macros are contained within this workbook becauses the three end
users access from a shared directory.

ASSISTANCE REQUEST
This problem occurs when the file name is changed. Is there a way to
update the code so it reflects the current workbook name?

ERROR:
Run-time error '1004':
Select method of Range class failed

MACRO
Sub MasterPTR2()
'
' MasterPTR2 Macro
' Macro recorded 1/30/2006 by B. Ann Bolland
'

'
Rows("5:800").Select
Selection.ClearContents
Range("A5").Select
Application.Run "'Project Tracking Report - 060127.xls'!Test4"
Application.Run "'Project Tracking Report -
060127.xls'!Master_Cleanup"
Application.CutCopyMode = False
Application.Run "'Project Tracking Report -
060127.xls'!Master_Cleanup2"
End Sub


--

Dave Peterson

Annabelle

Macro broken with workbook name change
 
This works great! Thank you for your help.



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

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