ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if statement (https://www.excelbanter.com/excel-programming/350031-if-statement.html)

ashw1984

if statement
 
hi does anybody know why this doesn't work

If IsNull("a6") = True Then
MsgBox "Error"
Exit Sub
End If

JE McGimpsey

if statement
 
Works for me.

The string "a6" isn't Null, so the instructions between Then and End If
are skipped.

It's also nearly impossible to tell what you mean by "doesn't work".
What are you trying to do?


In article ,
"ashw1984" wrote:

hi does anybody know why this doesn't work

If IsNull("a6") = True Then
MsgBox "Error"
Exit Sub
End If


ashw1984

if statement
 
sorry i want the statement the throw up an error messageand stop the macro,
if a6 is empty
if a6 isn't then i would like it to continue with the macro

"JE McGimpsey" wrote:

Works for me.

The string "a6" isn't Null, so the instructions between Then and End If
are skipped.

It's also nearly impossible to tell what you mean by "doesn't work".
What are you trying to do?


In article ,
"ashw1984" wrote:

hi does anybody know why this doesn't work

If IsNull("a6") = True Then
MsgBox "Error"
Exit Sub
End If



Dave Peterson

if statement
 
if isempty(worksheets("sheet99").range("a6")) then

or

if worksheets("sheet99").range("a6").value = "" then

or

if trim(worksheets("sheet99").range("a6").value) = "" then

Each test different things. The first if there's really nothing (not even a
formula) in the cell.

The second test if the cell is empty or has a formula that evaluates to ""
(like: =if(a11,"","ok") or if it has a zero length text in that cell (like an
apostrophe (')).

The third does the same thing as the second, but also checks for just space
characters, too--like:

=if(a11," ","ok")



ashw1984 wrote:

sorry i want the statement the throw up an error messageand stop the macro,
if a6 is empty
if a6 isn't then i would like it to continue with the macro

"JE McGimpsey" wrote:

Works for me.

The string "a6" isn't Null, so the instructions between Then and End If
are skipped.

It's also nearly impossible to tell what you mean by "doesn't work".
What are you trying to do?


In article ,
"ashw1984" wrote:

hi does anybody know why this doesn't work

If IsNull("a6") = True Then
MsgBox "Error"
Exit Sub
End If



--

Dave Peterson

JE McGimpsey

if statement
 
One way:

If IsEmpty(Range("A6").Value) Then
MsgBox "Error"
Exit Sub
End If


In article ,
"ashw1984" wrote:

sorry i want the statement the throw up an error messageand stop the macro,
if a6 is empty
if a6 isn't then i would like it to continue with the macro



All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com