Call Marco to run from VBA

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, I have written the following code, to copy relevant information into a different workbook, and then run a marco in that book. but it cannot find the Marco,
"Macro3" Have I missedsomething?

The data has pasted across,jut need t Marco to run.

Thak

Sheets("summary").Select

If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Cells.Select
Columns("b:cq").Select
Selection.EntireColumn.Hidden = True
Columns("cs").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Range("A:ct").AutoFilter Field:=1, Criteria1:="<>"
Range("a1:ct1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
ChDir _
"SQ Operations\SQ_Allocation\Classification Risk Score"
Workbooks.Open Filename:= _
"SQ Operations\SQ_Allocation\Classification Risk Score\Classification and Risk Score Import Template.xls"
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("2:2").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("A2").Select
Call Macro3

Columns("b:cq").Select
Selection.EntireColumn.Hidden = False
Columns("cs").Select
Selection.EntireColumn.Hidden = False
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Cells.Select
Sheets("macro").Select

Application.ScreenUpdating = True
Application.CutCopyMode = True
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I am Playing to try and get this to work, I have replace call macro3 with

Workbooks("Classification and Risk Score Import Template").Application.Run "'SQ Operations\SQ_Allocation\Classification Risk Score\Classification and Risk Score Import Template.xls' !macro3"

Still errors, but i can see it has found Macro3

just get a Run-ime erro 9 - subscript out of range
 
Upvote 0
Hi try

Code:
Application.Run ("'" & ActiveWorkbook.Name & "'!Macro3")

This assumes that Macro3 is in a standard module & has not been declared Private.


Dave
 
Upvote 0
just one further problem i cant resolve, Marco3 runs and closes the workbook correctly, how do i get the original code to complete?

Columns("b:ct").Select
Selection.EntireColumn.Hidden = False
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Cells.Select
Sheets("macro").Select

Application.ScreenUpdating = True
Application.CutCopyMode = True
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top