Windows 7 Macro VBA working but not with Window 10

Lauren279

Board Regular
Joined
Aug 19, 2014
Messages
95
I have a macro that works perfectly fine with Windows 7 and up until 3-4 days ago it was working fine on the window 10

The macro transfers data to another workbook, i have in place the correct file type / name etc etc and as stated above the macro works using a windows 7 computer

Would there be a reason for the macro to stop working stating the the "Run time error 9" "subscript out of range"

Am i missing something that can make it work again as it was before (it was working fine about 3-4 days ago)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
The cause is almost certainly something different than the change in Windows version. That particular error suggests a change to either your code or your data. It is either referring to an array element using an index that is not in the array, or a collection like Worksheets with a name that doesn't exist.

When asking for help with an error message always give the line of code that is causing the error. Please show all of your code (and use the VBA button to enclose it in code tags for readability) and indicate which line of code caused the error.
 
Upvote 0
Thanks Jeff
the code is below, sorry not sure if i have added it correctly ,
the reason i didn't include the code is that it works fine using the windows 7 computer, but not when i switch to windows 10 computer it stops at the IF statement
what is happening is that i am copying the information from a workbook called "Window 1" and when the cpv-main workbook is opens it stops at each section of the code when it reaches the IF statement of the VBA, when in the cpv-main workbook it will paste the information in 2 locations, but the exact same vba/macro is working on the W7 but not anymore on W10? even though it was in the past?


VBA Code:
Private Sub Workbook_Open()

If Workbooks("CPV - Main").Sheets("Start").Range("B60").Value > 1 Then
Sheets("Display").Select
      ActiveWindow.SelectedSheets.PrintOut From:=1, To:=4, Copies:=2, Collate _
            :=True, IgnorePrintAreas:=False
    Sheets("Start").Select
    Range("B1:B60").Select
        Selection.ClearContents
       Exit Sub
End If
End Sub
 
Upvote 0
i would also like to make a point of that it is only the macro that is referencing another workbook and completing a macro that involves another workbook on the windows 10 computer, all other macros so far work fine, it is only the transfer of data from one workbook to another that stops at the IF statement within the VBA and also another vba code that prints out a report that is in a different workbook (basically CPV-Main workbook is a master) and Window 1 is a data entry workbook
 
Upvote 0
Try adding the file extension to the file name in the Workbooks
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.

FYI you need to use the file extension, unless you have the "Hide extensions for known file types" checked in file explorer.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

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