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
So now I saved the workbook to a specific folder since it was in my downloads folder and named it the same "data" no changes to name just saved location, I open the Main workbook wher i have the code it opens i get no message box to see if the code is running but it also does not debug. and the following column is selected and blinks two times

1689957951069.png
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try putting a break point in your code at the first line of code, and then when it opens and runs, it will stop there, and you can view the VBA code and press the F8 key to run the code one line at time, and seeing where things are going haywire.
 
Upvote 0
Can you tell me how to add a break point, Its a little odd whats happening I added a Splash Screen on open and its working when I open the Workbook the splash screen opens closes after the 4 seconds like i wanted to. but the macro just does not want to run. Im not sure how to add a break point
 
Upvote 0
Can you tell me how to add a break point, Its a little odd whats happening I added a Splash Screen on open and its working when I open the Workbook the splash screen opens closes after the 4 seconds like i wanted to. but the macro just does not want to run. Im not sure how to add a break point
A simple Google search on "setting breakpoint in Excel VBA" will show you how to do that.
 
Upvote 0
I could be wrong, but i think you need to change

VBA Code:
Windows("data.xlsx").Activate
to
VBA Code:
Windows("data.xlsm").Activate
 
Upvote 0
Solution
I could be wrong, but i think you need to change

VBA Code:
Windows("data.xlsx").Activate
to
VBA Code:
Windows("data.xlsm").Activate
It depends entirely what the name & format of their file is.
The name and extension needs to match the exact name of their file exactly.

I was assuming that they already confirmed that part.
And if they are accessing another file, there is a good chance that other file (which looks like a data file), may not have VBA code in it, in which case it could be named with an "xlsx" extension.

It looks to me like the file that contains the VBA code is probably the second one that they refer to in their VBA code, and they have that marked as an "xlsm"
VBA Code:
Windows("FBN JBL OOR_TEST FILE.xlsm").Activate
 
Upvote 0
OK I did change the file name yesterday. This file name changed Windows("FBN JBL OOR_TEST FILE.xlsm").Activate but I also made the change to the VBA code. data workbook has no macros and the FBN JBL OOR_TEST FILE.xlsm" workbook which was changed has the macros.
 
Last edited:
Upvote 0
OK I did change the file name yesterday. This file name changed Windows("FBN JBL OOR_TEST FILE.xlsm").Activate but I also made the change to the VBA code. data workbook has no macros and the FBN JBL OOR_TEST FILE.xlsm" workbook which was changed has the macros.
 
Upvote 0
Its strange my splash screen that I just added this morning is working fine starts up on open but the rest of the macro does not work, its not debuging anymore but its not doing anything but blink after my splash screeen goes away
 
Upvote 0
Want to point out on my main workbook NEW NAM, " FBN & JBL OOR_AUTOMATED_v1.0.xlsm " is where I have my VBA to copy data from the data workbook I have it in a module. The Splash screen VBA I have under " This Workbook "
 
Upvote 0

Forum statistics

Threads
1,215,095
Messages
6,123,072
Members
449,093
Latest member
ripvw

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