
Use a user-defined function to check whether a
worksheet is empty
Sometimes it is necessary to check whether a worksheet is really
empty or still contains hidden formulas. To do this, choose
Worksheet from the Insert menu to add a new worksheet to the
current workbook and write a user-defined function in the Visual
Basic Editor as described below.
4
To check whether a worksheet is empty:
1. Press <Alt+F11> to open the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function ShEmpty(s As String) As Boolean
If Application.CountA (Sheets(s).UsedRange) = 0
Then
ShEmpty = True
Else
ShEmpty = False
End If
End Function
4.