My current code is below. In other Subs, I have .UsedRange.Delete available for each sheet depending on circumstances. However, even when all "Base" and "Corr" sheets are empty, I always get the MsgBox for "Too many Base sheets..."
Does anyone see what I'm missing?
Code Updated
Sub ViewResults()
'Counts number of empty "Base" sheets'
Dim i As Integer
Dim b_empty As Integer
b_empty = 0
If IsEmpty(Worksheets("Calypso (Zeiss) Base")) = True Then
b_empty = b_empty + 1
End If
If IsEmpty(Worksheets("Camio (LK) Base")) = True Then
b_empty = b_empty + 1
End If
If IsEmpty(Worksheets("Camio (Nikon) Base")) = True Then
b_empty = b_empty + 1
End If
If IsEmpty(Worksheets("GOM (Blue Light) Base")) = True Then
b_empty = b_empty + 1
End If
If IsEmpty(Worksheets("PC-DMIS (Global) Base")) = True Then
b_empty = b_empty + 1
End If
If IsEmpty(Worksheets("Quindos (HTA) Base")) = True Then
b_empty = b_empty + 1
End If
'Counts how many cempties are True'
Dim j As Integer
Dim c_empty As Integer
c_empty = 0
If IsEmpty(Worksheets("Calypso (Zeiss) Corr")) = True Then
c_empty = c_empty + 1
End If
If IsEmpty(Worksheets("Camio (LK) Corr")) = True Then
c_empty = c_empty + 1
End If
If IsEmpty(Worksheets("Camio (Nikon) Corr")) = True Then
c_empty = c_empty + 1
End If
If IsEmpty(Worksheets("GOM (Blue Light) Corr")) = True Then
c_empty = c_empty + 1
End If
If IsEmpty(Worksheets("PC-DMIS (Global) Corr")) = True Then
c_empty = c_empty + 1
End If
If IsEmpty(Worksheets("Quindos (HTA) Corr")) = True Then
c_empty = c_empty + 1
End If
'Test for correct number of non-empty base&corr sheets'
If b_empty > 5 Then
MsgBox "Base Data seems to be missing. Please Import Base Data.", vbOKOnly, "Missing Base Data"
End If
If b_empty < 5 Then
MsgBox "Too many Base sheets contain data. Please try again to Import Base Data.", vbOKOnly, "Too Much Base Data"
End If
If b_empty = 5 And c_empty > 5 Then
MsgBox "Corr Data seems to be missing. Please Import Corr Data.", vbOKOnly, "Missing Corr Data"
End If
If b_empty = 5 And c_empty < 5 Then
MsgBox "Too many Corr sheets contain data. Please try again to Import Corr Data.", vbOKOnly, "Too Much Corr Data"
End If
If b_empty = 5 And c_empty = 5 Then
Worksheets("Data Correlation").Activate
End If
On Error GoTo EmailSupport
Exit Sub
I originally had .cells.clear on all sheets in another Sub, but thought maybe there were residual objects, so changed all cases of .cells.clear to .usedrange.delete.
UPDATE: The code has been changed to ask the worksheets individually if they are empty and to update the count if True. Still getting the same MsgBox from condition 2