Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   If statement in excel macro not working correctly (https://www.askmehelpdesk.com/showthread.php?t=244606)

  • Aug 2, 2008, 03:46 PM
    rmccafferty
    if statement in excel macro not working correctly
    I tried to insert the following code into an Excel macro

    If Range("m1") = "" Then
    MsgBox ("Number of Units is blank")
    End If

    I am doing something wrong, because I get the msgbox whether cell m1 is empty or not. Can anyone help me with the correct syntax?
  • Aug 2, 2008, 05:35 PM
    jstrike
    That should work as long as you don't have a space in the cell...
    Try this:
    If Trim(Range("m1").Text) = "" Then
    MsgBox ("Number of Units is blank")
    End If

  • All times are GMT -7. The time now is 11:46 PM.