Simple problem in checking multiple sheets written cells

Klash Ville

Board Regular
Joined
Sep 19, 2017
Messages
83
For some reason, the code below, only the first variable ( i ) works, while the other one ( o ) doesn't, is simply ignored.

All I want to do is check if 2 sheets are empty or not (with no written cells).
Code:
For i = 1 To Worksheets.Count        
If Worksheets(i).Name = "Feuil1" Then
    exists = True
End If
    Next i
    If Not exists Then
        MsgBox "Apparently the sheet where you were suppose to upload an example of (Feuil1) doesn't exist" & vbNewLine & vbNewLine & _
        "• This is because it was either deleted or renamed into something different than its original name...", vbExclamation
        
        Sheets("Parameters").Select
        Exit Sub
    End If
    For o = 1 To Worksheets.Count
        If Worksheets(o).Name = "Country" Then
            exists = True
        End If
    Next o
    If Not exists Then
        MsgBox "Apparently the sheet where you were suppose to upload an example of (Country) doesn't exist" & vbNewLine & vbNewLine & _
        "• This is because it was either deleted or renamed into something different than its original name...", vbExclamation
        
        Sheets("Parameters").Select
        Exit Sub
    End If
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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