VBA Help

Hi,

Im trying to exit a sub    If ActiveSheet.Range("C92") = "0" Then

Ikeep getting that pesky error "next without for" on Next i

OIm a novice vba user, so any help would be great!

Sub Step_Thru_Booked()
    Dim slItem As SlicerItem
    Dim i As Long
    
Range("U23").Value = "=J2"
    
    
    Call Hide_All

    
    
    ActiveWorkbook.RefreshAll
    
    
   
    
    
    
  With ActiveWorkbook.SlicerCaches("Slicer_PCM_In_Country_Sales_Manager")
        '--deselect all items except the first
        .SlicerItems(1).Selected = True
        For Each slItem In .VisibleSlicerItems
            If slItem.Name <> .SlicerItems(1).Name Then _
                slItem.Selected = False
                
        Next slItem
        
        
        
      Call Print_PDF_Booked
        '--step through each item and run custom function
        For i = 2 To .SlicerItems.Count
            .SlicerItems(i).Selected = True
            .SlicerItems(i - 1).Selected = False
            
            If ActiveSheet.Range("C92") = "0" Then
            
            Exit Sub
            
            Else
            
            Call Print_PDF_Booked
            
            
        Next i
        
    
        
End With
  
  
End Sub

Open in new window

Seamus2626Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Call Print_PDF_Booked
        '--step through each item and run custom function
        For i = 2 To .SlicerItems.Count
            .SlicerItems(i).Selected = True
            .SlicerItems(i - 1).Selected = False
            
            If ActiveSheet.Range("C92") = "0" Then
            
            Exit Sub
            
            Else
            
            Call Print_PDF_Booked
           
            End If 
            
        Next i

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Seamus2626Author Commented:
Thanks my man!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.