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.
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.
Can't help without seeing the macros.
ASKER
Her are the macros
Code1
Code2
Code 3
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
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
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
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?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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'!Cr eateTree.C reateTree"
Application.Run "'C:My DocumentsFilename.xlsm'!Cr eateNew.Cr eateNew"
Application.Run "'C:My DocumentsFilename.xlsm'!Sa veAsCSV2.S aveCSV2"
End Sub
Sub Master()
Application.Run "'C:My DocumentsFilename.xlsm'!Cr
Application.Run "'C:My DocumentsFilename.xlsm'!Cr
Application.Run "'C:My DocumentsFilename.xlsm'!Sa
End Sub
Open in new window