Macro Not running

SantanaKRE8s

Board Regular
Joined
Jul 11, 2023
Messages
114
Office Version
  1. 365
Platform
  1. Windows
Macro stops when it has to get data from the "data" Workbook. I have a workbook that copies data from another workbook. The Macro was working but when I added the option to run the Macro automatically when I open the workbook it does not work.


Private Sub Workbook_Open()
'

Sheets("FAB & JAB OOR").Select

'
Windows("data.xlsx").Activate
Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("F2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("G2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("C3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("I2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("D3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("E3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("Q2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("F3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("Y2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("Z2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("H3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("AA2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("I3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("data.xlsx").Activate
Range("AR2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
Range("J3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Sheets("Dashboard").Select


End Sub
 

Attachments

  • DEBUG.png
    DEBUG.png
    42.9 KB · Views: 10
I switched the VBA code that copies the data from the data workbook from the module to the " This Workbook " and its debugging again
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Ok I added the Breakpoint to the VBA code in the data point and I hit run and it started to work, the data was transferred over to the main file. So How do I fix that?

1689975716380.png
 
Upvote 0
I deleted the MACRO and went ahead and redorded the macro again. How do I add the Workboo open() to that MACRO?
 
Upvote 0
I don't know. I haven't seen the new Macro, but the following will open a new Workbook:
VBA Code:
Dim myWb as Workbook
Set myWb = Workbooks.Open("Full_Address_Of_FileName") ' i.e. - C:\Users\Person\My Documents\Workbook.xlsm
 
Upvote 0
thank you Skyybot, This has been resolved and is working. Yes the extension was incorrect for the workbook that I was getting the data from. I was able to put the correct extension in my MACRO based on the type of excel sheet I was downloading from Power BI, and I added a run all to the workbook open and it worked. Splashscreen all Macros are working. Thnk you guys for the help and patience.
 
Upvote 0
thank you Skyybot, This has been resolved and is working. Yes the extension was incorrect for the workbook that I was getting the data from. I was able to put the correct extension in my MACRO based on the type of excel sheet I was downloading from Power BI, and I added a run all to the workbook open and it worked. Splashscreen all Macros are working. Thnk you guys for the help and patience.
Guess I shouldn't have assumed that you had already checked that!
Anyway, glad you got it figured out and thanks to all who joined forces to help out!
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

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