Skip function if data sheet is empty
Just need to use CountA to count the unempty cells in the data2
sheet. Something like:
Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.CountA(ws.Cells) = 0 Then
MsgBox "Worksheet '" & ws.Name & _
"' is empty. Can not proceed", , "Error"
End
End If
Of course, there are other ways of accomplishing this as well.
Hope this helps.
answer33 wrote:
Hi,
I have macro to extract data and then I use the information to built graph
and other things. The problem is when the data2 worksheet is empty (like if
that day I didn' run the machine) the program goes all the way to the end but
when I try to run it again I get an error message.
I would like to add a if statement (or somehting else) to look in the
worksheet data2 before it proceed with the rest of the programming and if
it's empty go to the end of the program and give me an empty worksheet
message.
|