Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Simple question?? Nested ifs on one line

I'm using Excel 2003.

This seems like it should be very simple, but I've tried lots of things, and
nothing works.

I have a large amount of "checks" to do so I would like to put 2 if
statements on one line.

I'd like to put this on one line:

If OneH < "" then
If OneH = YNewH then
goto DisplayMsg
end if
end if

Your help would be GREATLY appreciated!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Simple question?? Nested ifs on one line

You do not need two IF statements to accomplish the end product:

If OneH = YNewH Then
GoTo DisplayMsg
End If

The logic is that if OneH equals YNewH then it obviously is not equal to the
empty string.

But if you still want to check for the empty string, you can:

If OneH < "" And OneH = YNewH Then
GoTo DisplayMsg
End If

If you are asking whether the If statements can be nested, the answer is
yes, but I believe there is a limit of about 15 and each one must have an
End If. It might be easier to use the If...ElseIf...Else...End If format.
That format will handle many comparisons. See VBA help file for details.

Example:

If OneH < "" Then
'Do something or do nothing
ElseIf OneH = YNewH Then
GoTo DisplayMsg
Else
'Exit Sub maybe
End If




"laavista" wrote in message
...
I'm using Excel 2003.

This seems like it should be very simple, but I've tried lots of things,
and
nothing works.

I have a large amount of "checks" to do so I would like to put 2 if
statements on one line.

I'd like to put this on one line:

If OneH < "" then
If OneH = YNewH then
goto DisplayMsg
end if
end if

Your help would be GREATLY appreciated!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Simple question?? Nested ifs on one line

How about:
========
If OneH < "" And OneH = YNewH The Goto DisplayMsg
========

--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"laavista" wrote:

I'm using Excel 2003.

This seems like it should be very simple, but I've tried lots of things, and
nothing works.

I have a large amount of "checks" to do so I would like to put 2 if
statements on one line.

I'd like to put this on one line:

If OneH < "" then
If OneH = YNewH then
goto DisplayMsg
end if
end if

Your help would be GREATLY appreciated!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Simple question?? Nested ifs on one line

IT WORKED!! THANK YOU so much for taking the time to answer my question.

If was trying to add the "end if" at the end of the statement to no avail.

Thanks again. I really appreciate it!

"JBeaucaire" wrote:

How about:
========
If OneH < "" And OneH = YNewH The Goto DisplayMsg
========

--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"laavista" wrote:

I'm using Excel 2003.

This seems like it should be very simple, but I've tried lots of things, and
nothing works.

I have a large amount of "checks" to do so I would like to put 2 if
statements on one line.

I'd like to put this on one line:

If OneH < "" then
If OneH = YNewH then
goto DisplayMsg
end if
end if

Your help would be GREATLY appreciated!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Simple question?? Nested ifs on one line

Wouldn't it be easier just to write it as
If OneH = YNewH Then Goto DisplayMsg

If YNewH is anything, then it's not going to be blank, so for OneH to =
YNewH, then OneH can't be "", by definition. Of course, if there's a
possibility that YNewH could be = "", then the way you have it now is the
better way to go (and one that would work properly if YNewH can sometimes be
"").

"laavista" wrote:

IT WORKED!! THANK YOU so much for taking the time to answer my question.

If was trying to add the "end if" at the end of the statement to no avail.

Thanks again. I really appreciate it!

"JBeaucaire" wrote:

How about:
========
If OneH < "" And OneH = YNewH The Goto DisplayMsg
========

--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"laavista" wrote:

I'm using Excel 2003.

This seems like it should be very simple, but I've tried lots of things, and
nothing works.

I have a large amount of "checks" to do so I would like to put 2 if
statements on one line.

I'd like to put this on one line:

If OneH < "" then
If OneH = YNewH then
goto DisplayMsg
end if
end if

Your help would be GREATLY appreciated!

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
Simple nested if statement mike_vr Excel Discussion (Misc queries) 1 September 29th 08 03:35 PM
simple nested loop question fedude Excel Programming 8 March 2nd 08 05:04 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple Question (insert new line) Joe D[_4_] Excel Programming 3 July 27th 05 03:52 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM


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

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

About Us

"It's about Microsoft Excel"