We help IT Professionals succeed at work.

Running Multiple Macros in Excel Simultaneously

fb1990
fb1990 asked
on
4,071 Views
Last Modified: 2014-05-07
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.
Comment
Watch Question

Commented:
Might be a mis-spelled macro name..

Public Sub RunEm()
macroname1
macroname2
macroname3
End Sub

Open in new window

CERTIFIED EXPERT

Commented:
Can't help without seeing the macros.

Author

Commented:
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

CERTIFIED EXPERT

Commented:
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?

Author

Commented:
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
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
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.

Author

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.