Subscript out of range

wcd45

New Member
Joined
Jan 28, 2014
Messages
3
I keep getting an error message saying subscript out of range with this code.



Sub Check_First()
Dim Z As Integer


Z = 1


Do While Z <= Range("o1").Value
Range("r1").Value = Z
Range("AH2").Select
Range("A2:AJ2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=34, Criteria1:=Range("r1").Value
Sheets("EQ1 No Tickets1").PrintOut
Z = Z + 1
Loop
MsgBox "The Do While loop made " & Z & " loop(s)."


End Sub

All help is very much appreciated by this novice.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Fazza

MrExcel MVP
Joined
May 17, 2006
Messages
9,368
Have you tried single stepping through the code? Refer Debugging VBA

The code worked OK for me. Where is the code & how/when do you execute it? Can you provide an image of your worksheet?
 

wcd45

New Member
Joined
Jan 28, 2014
Messages
3
I should have clarified. I'm getting the error message when I try to print. Late last night I came up with a solution. Since I am trying to make additions to someone else's work, I decided to take out Sheets("EQ1 No Tickets1").PrintOut and instead just call a macro that was already being used to print. This fixed my issue. But thank you for trying to help.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,507
Messages
5,596,544
Members
414,077
Latest member
ammylar5

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
Top