Ask Experts Questions for FREE Help !
Ask
    rmccafferty's Avatar
    rmccafferty Posts: 15, Reputation: 1
    New Member
     
    #1

    Aug 2, 2008, 03:46 PM
    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?
    jstrike's Avatar
    jstrike Posts: 418, Reputation: 44
    Full Member
     
    #2

    Aug 2, 2008, 05:35 PM
    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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Auto-Macro in Excel [ 4 Answers ]

Hi, I have a lot of macros built-in Excel, but when I want to update the certain data , I have to run them individually each time. Do you know anyway I can auto-run these macros? Thanks for any help.

Recording a macro in Excel [ 2 Answers ]

Need a macro that will select the cell one place to the left, edit the content, hit enter, and then move to cell below where started and repeat to end of column (last cell with a value). Example: 123-456789 is format of cell to be edited - need to remove the hyphen. Someone had created it...

How to Automate a macro in excel [ 4 Answers ]

A program logs files at random in txt. abc_log.txt (example) When new info. Is added to the txt file,manualy activate macro and it does what it suppose to do, all OK there. Is there a way a macro code or excel, or perhaps a BAT program can be made to simply "detect" when new data is added...


View more questions Search