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.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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