Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default need help on following nested if statement

Hello: I'm trying to do the following on VBA:

If a cell contains the word "day" then write today's date, if not
leave blank.

If [e11] = "day" then [g11] = now Else [g11] = ""

however if I wanted to include more criteria, i.e., different
additional days (I believe the term is 'nested if statements') how
do I go about it.

For example:

If [e11] = "day" then [g11] = Now Else [g11] = ""
If [e11] = "T + 1" then [g11] = Now + 1 Else [g11] = ""
If [e11] = "T + 2" then [g11] = Now + 2 Else [g11] = ""
If [e11] = "T + 3" then [g11] = Now + 3 Else [g11] = ""
If [e11] = "T + 4" then [g11] = Now + 4 Else [g11] = ""


Thank you in advance

Manuel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default need help on following nested if statement

Manuel,

The rule of thumb is:
If(This,That,Else)
If(This,That,If(this,that,If(..........)))
Just keep replace Else with If(This,That,Else)

The tricky part is remembering all the "," and ")"
--
sb
<billabong wrote in message
...
Hello: I'm trying to do the following on VBA:

If a cell contains the word "day" then write today's date, if not
leave blank.

If [e11] = "day" then [g11] = now Else [g11] = ""

however if I wanted to include more criteria, i.e., different
additional days (I believe the term is 'nested if statements') how
do I go about it.

For example:

If [e11] = "day" then [g11] = Now Else [g11] = ""
If [e11] = "T + 1" then [g11] = Now + 1 Else [g11] = ""
If [e11] = "T + 2" then [g11] = Now + 2 Else [g11] = ""
If [e11] = "T + 3" then [g11] = Now + 3 Else [g11] = ""
If [e11] = "T + 4" then [g11] = Now + 4 Else [g11] = ""


Thank you in advance

Manuel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default need help on following nested if statement

billabong,

One way-

If [e11] = "day" Then
[g11] = Now
ElseIf [e11] = "T + 1" Then
[g11] = Now + 1
ElseIf [e11] = "T + 2" Then
[g11] = Now + 2
ElseIf [e11] = "T + 3" Then
[g11] = Now + 3
ElseIf [e11] = "T + 4" Then
[g11] = Now + 4
Else
[g11] = ""
End If

regards,

JohnI

<billabong wrote in message
...
Hello: I'm trying to do the following on VBA:

If a cell contains the word "day" then write today's date, if not
leave blank.

If [e11] = "day" then [g11] = now Else [g11] = ""

however if I wanted to include more criteria, i.e., different
additional days (I believe the term is 'nested if statements') how
do I go about it.

For example:

If [e11] = "day" then [g11] = Now Else [g11] = ""
If [e11] = "T + 1" then [g11] = Now + 1 Else [g11] = ""
If [e11] = "T + 2" then [g11] = Now + 2 Else [g11] = ""
If [e11] = "T + 3" then [g11] = Now + 3 Else [g11] = ""
If [e11] = "T + 4" then [g11] = Now + 4 Else [g11] = ""


Thank you in advance

Manuel



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default need help on following nested if statement

see ans in LATER post. "We must learn to have patience"

<billabong wrote in message
...
Hello: I'm trying to do the following on VBA:

If a cell contains the word "day" then write today's date, if not
leave blank.

If [e11] = "day" then [g11] = now Else [g11] = ""

however if I wanted to include more criteria, i.e., different
additional days (I believe the term is 'nested if statements') how
do I go about it.

For example:

If [e11] = "day" then [g11] = Now Else [g11] = ""
If [e11] = "T + 1" then [g11] = Now + 1 Else [g11] = ""
If [e11] = "T + 2" then [g11] = Now + 2 Else [g11] = ""
If [e11] = "T + 3" then [g11] = Now + 3 Else [g11] = ""
If [e11] = "T + 4" then [g11] = Now + 4 Else [g11] = ""


Thank you in advance

Manuel



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
Help with nested IF statement Raven Excel Worksheet Functions 0 December 13th 10 09:19 PM
Nested IF statement DG Excel Discussion (Misc queries) 3 June 10th 09 09:38 PM
Nested IF statement not need help wtamustudentmc Excel Discussion (Misc queries) 3 March 7th 09 11:03 PM
Nested If Statement teethomas Excel Worksheet Functions 7 September 11th 08 10:06 PM
IF and OR nested statement help [email protected] Excel Discussion (Misc queries) 4 July 16th 07 10:22 PM


All times are GMT +1. The time now is 12:51 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"