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.
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.
Here is the code in its entirety:
Any help resolving this would be greatly appreciated!
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!