Accessing Isblank In Vba

  • Re: Accessing Isblank In Vba


    vba has it's own methods so the worksheet function is not supported via the object model.


    try either of these
    [vba] If Cells(RowIndex, ColIndex) = "" Then

    If Len(Cells(RowIndex, ColIndex)) = 0 Then
    [/vba]

  • Re: Accessing Isblank In Vba


    Quote from Om Avataar

    Is the following valid code in Excel VBA?


    Code
    If Application.WorksheetFunction.isblank(Cells(RowIndex, ColIndex)) Then


    Thanks


    Do you use some Loop? The best way for it:

    Code
    For each EmptyCell in YourRange.SpecialCells(xlCellTypeBlanks)
    Next EmptyCell


    or

    Code
    For each NonEmptyCell in YourRange.SpecialCells(xlCellTypeConstants)
    Next NonEmptyCell


    Or you can Access to IsBlank function by:

    Code
    If Evaluate("Isblank(" & Cells(RowIndex, ColIndex).address & ")") Then


    But I suggest you to use SpecialCells method if it's possible.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!