Adjust VBA code to remove subscript out range error

39 Views Asked by At

Trying to remove this error from my spreadsheets where I have similar code multiple times. I am a novice for VBA and this keeps failing every few months with the subscript out of range error.

Sub DailyConvert()
        Application.EnableEvents = False
With Workbooks("Dash")
        Sheets("Dashboard").Range("DQ4:DQ250").Clear
        Sheets("Movers).Range("C5:C250").Copy Destination:=Sheets("Dashboard").Range("DQ4")
End With
        Application.EnableEvents = True
End Sub 

I know I need to declare variables and have tried a few attempts but it keeps failing. Any help is greatly appreciated.

Thank you.

1

There are 1 best solutions below

0
JupBrew On
Sub DailyConvert()
        Application.EnableEvents = False
With Workbooks("Dash")
        .Sheets("Dashboard").Range("DQ4:DQ250").Clear
        .Sheets("Movers").Range("C5:C250").Copy Destination:=Sheets("Dashboard").Range("DQ4")
End With
        Application.EnableEvents = True
End Sub 

Adding the period to the start of the sheets seems to have fixed it. Thank you Warcupine! And I guess I meant ranges, not variables. Taller thank you, just a typing error. And Tim I will add the full file extension as well if that will help.

Thank you all.