Thanks, snb.
I think I understand the logic, although I cannot fathom what "it" is to be able to make this work.
Printable View
It even works without you understanding the code.
I'd really like to understand it as at the moment, I'm getting a "variable not defined" on 'it'.
I've tried substituting 'it' for the variable I had set for worksheet ('ws'), but this still doesn't work stating that "variable not defined" here
Code:Then y = y + 1
Solved the problem!
Code:Private Sub cmdWarning_Markers_Click()
Application.ScreenUpdating = False
Set ws = ThisWorkbook.Worksheets("Warning_Markers1")
Sheets("Warning_Markers1").Activate
With ws
If WorksheetFunction.CountA(Cells) = 0 Then
MsgBox ws.name & " is empty"
ElseIf WorksheetFunction.CountA(Cells) <> 0 Then
' Perform a check to make sure that the macro hasn't already been run
' If it hasn't, then run it
If Range("B1").Value = "Type" Then
Warning_Markers
ElseIf Range("B1").Value <> "Type" Then
Exit Sub
End If
End If
End With
Set ws = ThisWorkbook.Worksheets("Warning_Markers2")
Sheets("Warning_Markers2").Activate
With ws
If WorksheetFunction.CountA(Cells) = 0 Then
MsgBox ws.name & " is empty"
ElseIf WorksheetFunction.CountA(Cells) <> 0 Then
' Perform a check to make sure that the macro hasn't already been run
' If it hasn't, then run it
If Range("B1").Value = "Type" Then
Warning_Markers
ElseIf Range("B1").Value <> "Type" Then
Exit Sub
End If
End If
End With
Exit Sub
Application.ScreenUpdating = True
End Sub