Lester
11-01-2007, 05:12 AM
Hello again,
Thanks for the help thus far...I have another query.
I recorded the following macro, then exported it for use with other excel files:
Sub CalculateCostandSales()
'
' CalculateCostandSales Macro
' Macro recorded 01/11/2007 by Les
'
' Keyboard Shortcut: Ctrl+g
'
Application.Run "'Temp Company Data.xls'!ImportLookUp"
Sheets("Sheet6").Select
Application.Run "'Temp Company Data.xls'!ProcessSalesAndCosts"
End Sub
I can import it into the new excel file ok, but the problem is that it still contains references to the original excel file 'Temp Company Data.xls' where the macro was recorded.
Hence, I get the following '1004' run-time error.
'Temp Company Data.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.
The debugger then highlights the line Application.Run "'Temp Company Data.xls'!ImportLookUp
Does anyone know how to make the macro 'generic' so it can work in any excel file that imports it? :(
Many thanks for your help.
Lester.
Thanks for the help thus far...I have another query.
I recorded the following macro, then exported it for use with other excel files:
Sub CalculateCostandSales()
'
' CalculateCostandSales Macro
' Macro recorded 01/11/2007 by Les
'
' Keyboard Shortcut: Ctrl+g
'
Application.Run "'Temp Company Data.xls'!ImportLookUp"
Sheets("Sheet6").Select
Application.Run "'Temp Company Data.xls'!ProcessSalesAndCosts"
End Sub
I can import it into the new excel file ok, but the problem is that it still contains references to the original excel file 'Temp Company Data.xls' where the macro was recorded.
Hence, I get the following '1004' run-time error.
'Temp Company Data.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.
The debugger then highlights the line Application.Run "'Temp Company Data.xls'!ImportLookUp
Does anyone know how to make the macro 'generic' so it can work in any excel file that imports it? :(
Many thanks for your help.
Lester.