Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    IF - testing condtions (Excel 2000)

    Hi all,

    I have a quick question,

    I have an If statement, that I need some help with


    I'm testing for 2 conditions....1 if there is no Text in the Activecell, and if there is Text....
    If Activecell.value = " " then ------------If there was Text in the Activecell, how would statement look?

    Else if
    Activecell.value="Somestring" ----------some string would mean any value.
    Msgbox
    End if
    End Sub

    What I have now doesn't work.

    Thanks, Darryl.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IF - testing condtions (Excel 2000)

    Your first If is NOT checking for no text in the active cell, it is checking for a single space character. What is your definition of there being text or no text in a cell? If the cell contains one or more blanks, does it contain text? If the cell contains a number, does it contain text? If the cell contains a formula that results in a numeric value, does it contain text? If the cell contains a number that has been formatted as text (ie. it has a single quote in front of it, or the cell is formatted as text), does the cell contain text?

    Depending on exactly what you are trying to do, you might use:

    <pre> If ActiveCell.Value = "" Then
    ' code for empty cell
    Else
    If Not IsNumeric(ActiveCell.Value) Then
    MsgBox
    End If
    End If
    </pre>

    Legare Coleman

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: IF - testing condtions (Excel 2000)

    Additionally, if you want to truly test for a blank/empty cell and not a null string or a formula giving a null:

    If isempty(ActiveCell) Then

    Steve

  4. #4
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: IF - testing condtions (Excel 2000)

    Thank you guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •