Avatar of fb1990
fb1990
 asked on

Running Multiple Macros in Excel Simultaneously

Hello EE,

I have 3 sets of macros in my excel workbook.  I created a fourth macro to run the other 3 macros, but i am getting

Compile Error:  
                      Expected variable or procedure, not module

Can someone please help me?

Thanks.
Microsoft Excel

Avatar of undefined
Last Comment
fb1990

8/22/2022 - Mon
Steve

Might be a mis-spelled macro name..

Public Sub RunEm()
macroname1
macroname2
macroname3
End Sub

Open in new window

Joe Howard

Can't help without seeing the macros.
fb1990

ASKER
Her are the macros

Code1

Sub CreateTree()

    Set DestSht = Sheets.Add(After:=Sheets(Sheets.Count))
    DestSht.Name = "Tree"
    Sheets("Data10").Columns("O:O").Copy Destination:=DestSht.Range("D1")
    Sheets("Data10").Columns("C:C").Copy Destination:=DestSht.Range("E1")
    Sheets("Data10").Columns("J:J").Copy Destination:=DestSht.Range("G1")

    Application.CutCopyMode = False
    
End Sub

Open in new window


Code2

Sub Createnew()
    Sheets("Data10").Range("J1").AutoFilter
    Set DestSht = Sheets.Add(After:=Sheets(Sheets.Count))
    DestSht.Name = "Winners"
    Sheets("Data10").Columns("A:A").Copy Destination:=DestSht.Range("A1")
    Sheets("Data10").Columns("B:B").Copy Destination:=DestSht.Range("B1")
    Sheets("Data10").Columns("D:D").Copy Destination:=DestSht.Range("C1")
    Sheets("Data10").Columns("E:E").Copy Destination:=DestSht.Range("D1")
    Sheets("Data10").Columns("G:G").Copy Destination:=DestSht.Range("E1")
    Sheets("Data10").Columns("J:J").Copy Destination:=DestSht.Range("F1")
    Sheets("Data10").Columns("K:K").Copy Destination:=DestSht.Range("G1")
    Sheets("Data10").Columns("P:P").Copy Destination:=DestSht.Range("H1")

    Application.CutCopyMode = False
    Sheets("Data10").Range("J1").AutoFilter
End Sub

Open in new window


Code 3

Sub SaveWorksheetsAsCsv()

Dim ws As Worksheet, wb As Workbook

    For Each ws In ThisWorkbook.Worksheets
        ws.Copy 'creates a new workbook
        With ActiveWorkbook
            .SaveAs "C:\Users\xxx\" & ws.Name & ".csv", xlCSV
            .Close False
        End With
    Next ws

End Sub

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Joe Howard

There are no compile (or runtime) errors in the code you provided, the error must be somewhere else, Which line gets selected when you encounter the error?
fb1990

ASKER
I get the error when i run this code that was placed in another module

Sub AllCombined()

 Call CreateTree
 Call Createnew
 Call SaveWorksheetsAsCsv
 
End Sub
 error
ASKER CERTIFIED SOLUTION
Joe Howard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rory Archibald

Also, if you gave the module the same name as the procedure, you would get the error message you originally mentioned. It's generally considered bad practice to do that, so rename the module and then the Call code should work.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
fb1990

ASKER
Thanks to everyone that contributed.  For some reason the solution did not work for me, but i got some idea from the assistance that was provided.  Here is the solution that worked for me

Sub Master()

Application.Run "'C:My DocumentsFilename.xlsm'!CreateTree.CreateTree"
Application.Run "'C:My DocumentsFilename.xlsm'!CreateNew.CreateNew"
Application.Run "'C:My DocumentsFilename.xlsm'!SaveAsCSV2.SaveCSV2"

End Sub