VBA ISNUMBER, ISTEXT functions

  • I am trying to create code that deletes lines in a spreadsheet when the first column is either blank or has text in it. However, when writing the VBA code, ISNUMBER and ISTEXT do not work. Amazingly, ISBLANK does work.


    Any clues will be greatley appreciated.

  • Re: VBA ISNUMBER, ISTEXT functions


    Hi anson10x and welcome,


    You can use the worksheet function in your code or use the VBA function.


    Code
    Sub x()
    
    
        If Application.WorksheetFunction.IsText(Range("A1")) Then MsgBox "IsText"
        If Application.WorksheetFunction.IsNumber(Range("A1")) Then MsgBox "IsNumber"
        
        If IsNumeric(Range("A1")) Then MsgBox "IsNumeric"
        
    End Sub
  • Re: VBA ISNUMBER, ISTEXT functions


    Quote from anson10x

    I am trying to create code that deletes lines in a spreadsheet when the first column is either blank or has text in it. However, when writing the VBA code, ISNUMBER and ISTEXT do not work. Amazingly, ISBLANK does work.


    Any clues will be greatley appreciated.



    when the entire column is blank or has text? Or if a cell in column a is blank/text it deletes that entire row?

  • Re: VBA ISNUMBER, ISTEXT functions


    When the entire column is blank or has text? Or if a cell in column a is blank/text it delet? I wanted to delete the entire row if the first cell is text, blank but not a number.


    Andy Pope: Many thanks for the code. It solved my problem and I'm on my way again.

Participate now!

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