Running macro for another workbook - dosen't wrok


New Member
Aug 22, 2008

I have a macro that is to run three macros in another file
Two of them run fine but the third I get an error on

This is the code for running the macros

Workbooks.Open Filename:=FileNameFolder & xlsmFile

Application.Run "'" & xlsmFile & "'!UpdateSummarySheet"
'woks fine
Application.Run "'" & xlsmFile & "'!CreateCostBreakdownSheet"
'works fine
Application.Run "'" & xlsmFile & "'!Remove"
'generates an error

This is the macro that I can't get to run from the other workbook
Is it the "Option Explicit" that is the problem?

Option Explicit
Public Sub Remove()
If MsgBox("Are you sure you want to delete the buttons?", vbOKCancel, "PCR Template") = vbCancel Then
Exit Sub
End If
Application.DisplayAlerts = False
Dim wb As Excel.Workbook
Set wb = ActiveWorkbook
Dim FileName As String
FileName = wb.Path & "" & Left(wb.Name, Len(wb.Name) - 5) & "_Cust.xlsm"
wb.SaveAs FileName

Dim ws As Excel.Worksheet
For Each ws In wb.Worksheets
Next ws

Set ws = wb.Sheets("SupplierSheet")
ws.Visible = xlSheetHidden

Application.DisplayAlerts = True
End Sub


Well-known Member
Aug 31, 2016
OPTION EXPLICIT assists you in identifying if there is an error in your coding and where it is located.

Have you tried running that third macro, by itself, in the other file ? Does it really work or are you assuming such ?

If you step through that macro line by line, where does it error out ? (Place your cursor at the beginning of the macro, then press F8 one at a time.
If there is truly an error with the code it should provide an error code and highlight in yellow the line of code containing the error.


New Member
Aug 22, 2008
Hi Logit and thanks for your interest :)

I have run them one by one but get the same result

this is the error I get from the "Remove" macro, It's like it can find it

-- removed inline image ---

When I open the Macro management dialog box it looks a little strange to me
Some of the macros have the file name infront of the macro name, that is not as it ussaly looks?
What I can see also the Module name is part of the "macro name" hmm...

-- removed inline image ---


MrExcel MVP
Dec 9, 2008
Is Remove() in a Standard Module (not a worksheet's module) in the other workbook? If yes, I'd first try renaming the Sub.


New Member
Aug 22, 2008
It looks like this

-- removed inline image ---

-- removed inline image ---

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...