Excel VBA Determines whether a worksheet is empty or used (such as setting a border)

Source: Internet
Author: User

Boolean value indicating whether the variable has been initialized. "Syntax" IsEmpty (expression) The necessary expression argument is a Variant that contains a numeric or string expression (which can actually also be a cell). However, because IsEmpty is used to determine whether individual variables have been initialized,
True False. If expression contains more than one variable , False.
IsEmpty only returns information that is meaningful to the variant expression.

'determine if a worksheet is using a custom functionFunctionIsusedsheet (ByValSheet asWorksheet) as BooleanIsusedsheet=IsEmpty (sheet. UsedRange)End Function'Determine whether a worksheet is an empty worksheet (that is, the value of the cell is empty) custom functionFunctionIsemptysheet (ByValSheet asWorksheet) as Boolean    IfApplication.WorksheetFunction.CountA (sheet. Cells) >0  ThenIsemptysheet=False    ElseIsemptysheet=True    End IfEnd FunctionSubShttest ()'Test    DimSht1 asWorksheet for  eachSht1inchSheets Debug.Print sht1. Name&"Is empty?"&Isemptysheet (sht1) Debug.Print sht1. Name&"Is used?"&Isusedsheet (sht1)Next    End Sub

Excel VBA Determines whether a worksheet is empty or used (such as setting a border)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.