Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default If statement and exit macro

I want that is the statement is true, give me a message and stop the macro,
if cell Ki is empty. If the cell contain data I would like to continue with
the macro. But when I run the macro for test, if the cell contain data gave
me the message and top the macro. What is wrong?

For i = 1 To nLastRow + 1 - nFirstRow
If Trim(wsSystem.Cells(i, 11)) = "" Or IsEmpty(wsSystem.Cells(i,
11)) Or IsNull(wsSystem.Cells(i, 11)) Then
MsgBox "You do not indicated if the System need a Critical or
Non-Critical Overall Assessment"
Exit Sub
End If
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default If statement and exit macro

abdrums,

I tried this code out on a test sheet, and it worked fine for me. Are you
sure you are defining your row variables correctly? Try using the Immediate
Window and Debug.Print to follow the code, also.

Pflugs

"abdrums" wrote:

I want that is the statement is true, give me a message and stop the macro,
if cell Ki is empty. If the cell contain data I would like to continue with
the macro. But when I run the macro for test, if the cell contain data gave
me the message and top the macro. What is wrong?

For i = 1 To nLastRow + 1 - nFirstRow
If Trim(wsSystem.Cells(i, 11)) = "" Or IsEmpty(wsSystem.Cells(i,
11)) Or IsNull(wsSystem.Cells(i, 11)) Then
MsgBox "You do not indicated if the System need a Critical or
Non-Critical Overall Assessment"
Exit Sub
End If
Next i

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default If statement and exit macro

What was in the cell that gave you the warning?
(Maybe adding
msgbox wssystem.cells(i,11).value & vblf & i
would help)

And I'd just use that first portion to check for "emptyness":

If Trim(wsSystem.Cells(i, 11).value) = "" then


If the cell is empty, then trim() will be "". And isnull doesn't do what you
think.

abdrums wrote:

I want that is the statement is true, give me a message and stop the macro,
if cell Ki is empty. If the cell contain data I would like to continue with
the macro. But when I run the macro for test, if the cell contain data gave
me the message and top the macro. What is wrong?

For i = 1 To nLastRow + 1 - nFirstRow
If Trim(wsSystem.Cells(i, 11)) = "" Or IsEmpty(wsSystem.Cells(i,
11)) Or IsNull(wsSystem.Cells(i, 11)) Then
MsgBox "You do not indicated if the System need a Critical or
Non-Critical Overall Assessment"
Exit Sub
End If
Next i


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a macro on exit More Macro Help Needed Excel Programming 3 January 11th 10 11:34 PM
Run macro on exit Steve Excel Discussion (Misc queries) 12 October 25th 09 01:43 PM
Exit via macro only? Brisbane Rob Excel Discussion (Misc queries) 1 October 13th 05 01:16 PM
on exit macro ditchy Excel Discussion (Misc queries) 2 May 3rd 05 12:11 AM
statement to Exit Do if empty row Mike[_89_] Excel Programming 3 October 1st 04 03:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"