Subscript out of range VBA help

Felix_Dragonhammer

Board Regular
Joined
Apr 7, 2015
Messages
117
Hello, I am having a spot of trouble.

I have a code that keeps giving me Subscript our of range errors.
Code:
Windows("WTD Sales-InvGPAU.xlsm").Activate
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("C3:C1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("A1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("D3:D1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("C1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("F3:G1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("E1")
    Workbooks("WM - WBM Game Plan AU.xlsm").Activate

The real humdinger is that I have what I'm pretty sure is virtually the exact same code in a module for another book that works perfectly. The only difference I've been able to detect so far is that the last two lines are different, but that's because they refer to different workbooks.

Here is the bit from the other workbook.

Code:
Windows("WTD Sales-InvGPAU.xlsm").Activate
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("C3:C1000").Copy Destination:=Workbooks("WM - Rider Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("A1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("D3:D1000").Copy Destination:=Workbooks("WM - Rider Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("C1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("F3:G1000").Copy Destination:=Workbooks("WM - Rider Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("E1")
    Workbooks("WM - Rider Game Plan AU.xlsm").Activate


Here is the code in its entirety:
Code:
Sub GamePlanAutoUpdate()
'
' GamePlanAutoUpdate Macro
'
' Keyboard Shortcut: Ctrl+Shift+U
'
'
' POS Tracking Update
'
    Windows("WM - WBM Game Plan AU.xlsm").Activate
    Sheets("POS Tracking").Range("B3") = Range("B3") + 1
    ColToRef = Range("B3").Value
    ColToRef = ColToRef + 5
For n = 17 To 65 Step 6
    Cells(n, 10).Copy
    Cells(n, ColToRef).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Next n
Application.CutCopyMode = False
ColToRef1 = Range("B3").Value
ColToRef1 = ColToRef1 + 5
For n = 11 To 65 Step 6
    With Cells(n, ColToRef1).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.149998474074526
        .PatternTintAndShade = 0
    End With
Next n
'
'MTD Production Schedule Update
'
    Workbooks("ProductionGPAU.xlsm").Sheets("Page1_1").Range("A3:D50000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("MTD Production Schedule").Range("A3")
    
'
'MTD Inventory Update
'
    Workbooks("MTDInventoryGPAU.xlsm").Sheets("Page1_1").Range("A2:D10000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("MTD Inventory").Range("A2")
    
    Application.CutCopyMode = False
'
'POS Chart and Wks of Supply Chart Update
'
Sheets("POS Chart").Select
    ActiveSheet.Shapes.Range(Array("Straight Connector 3")).Select
    Selection.ShapeRange.IncrementLeft 45
    Sheets("Wks of Supply Chart").Select
    Selection.ShapeRange.IncrementLeft 46.0714173228
'
'Lowes Inventory Update
'
    Windows("WTD Sales-InvGPAU.xlsm").Activate
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("C3:C1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("A1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("D3:D1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("C1")
    Workbooks("WTD Sales-InvGPAU.xlsm").Sheets("Daily Inventory - Item").Range("F3:G1000").Copy Destination:=Workbooks("WM - WBM Game Plan AU.xlsm").Sheets("Lowes Inventory").Range("E1")
    Workbooks("WM - WBM Game Plan AU.xlsm").Activate
'
'Chart Data Update
'
Sheets("Chart Data").Select
ColToRef4 = Range("B5").Value
    Sheets("Chart Data").Range("F67:F89").Copy
    Cells(67, ColToRef4).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
        
'
'SKU Tracking Sheet Update
'
Sheets("SKU Tracking Sheet").Select
ColToRef2 = Range("Y2").Value
ColToRef3 = Range("Z2").Value
    For n = 7 To 73 Step 22
        Cells(n, ColToRef2).Copy Destination:=Cells(n, ColToRef3)
    Next n
Cells(249, ColToRef2).Copy Destination:=Cells(249, ColToRef3)
Application.CutCopyMode = False
Sheets("POS Tracking").Select
'
'Last Date Updated
'
With Range("Date1")
 .Value = Date
 .NumberFormat = "mm/dd/yyyy"
 End With
MsgBox "              Done!"
 
End Sub

Any help resolving this would be greatly appreciated!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I was able to resolve my question. The parts where it said Lowes in the first one should have said WM. I swear, VBA can be quite maddening.
 
Upvote 0

Forum statistics

Threads
1,203,099
Messages
6,053,523
Members
444,669
Latest member
Renarian

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