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

Hi, could sumone pls help me with a nested if statement...
I want to assign a number to a cell depending on wat the contents of
another cell is.

eg: 100 - 104 assign 40
105-109 assign 44
110-114 assign 47
115+ assign 50

this is 1 if statement, id like to also add anothr nested if statement
to that same cell...

any suggestion? Thanx in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default If..statement

Try using a case statement:


Sub Test()
Select Case Range("A1").Value
Case 100 To 104
Range("B1").Value = 40
Case 105 To 109
Range("B1").Value = 44
Case 110 To 114
Range("B1").Value = 47
Case Is = 115
Range("B1").Value = 50
End Select
End Sub

Sandy
amatuer wrote:
Hi, could sumone pls help me with a nested if statement...
I want to assign a number to a cell depending on wat the contents of
another cell is.

eg: 100 - 104 assign 40
105-109 assign 44
110-114 assign 47
115+ assign 50

this is 1 if statement, id like to also add anothr nested if statement
to that same cell...

any suggestion? Thanx in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default If..statement

Hi Sandy, could you expand a little for me please. Where exactly whould
i put the sub? And hw should i call the sub.
Thanx sooo much.


Sandy wrote:
Try using a case statement:


Sub Test()
Select Case Range("A1").Value
Case 100 To 104
Range("B1").Value = 40
Case 105 To 109
Range("B1").Value = 44
Case 110 To 114
Range("B1").Value = 47
Case Is = 115
Range("B1").Value = 50
End Select
End Sub

Sandy
amatuer wrote:
Hi, could sumone pls help me with a nested if statement...
I want to assign a number to a cell depending on wat the contents of
another cell is.

eg: 100 - 104 assign 40
105-109 assign 44
110-114 assign 47
115+ assign 50

this is 1 if statement, id like to also add anothr nested if statement
to that same cell...

any suggestion? Thanx in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default If..statement

If you weren't looking for a macro you could use this if function in a
cell(change A1 to what ever reference you'd like):

=IF(AND(A1=100,A1<=104),40,IF(AND(A1=105,A1<=109 ),44,IF(AND(A1=110,A1<=114),47,IF(A1=115,50,"Not hing"))))

If you want to use the macro:

open VBE (Alt +F11)
Click insert == Module paste the formula in the window.
To run click Tools == macro == marcos and highlight "Test" and click
play.

You'll need to change the ranges to the cell you want to change. If
you're not that well versed in VBA code I would recommend using the
formula instead

Sandy

amatuer wrote:
Hi Sandy, could you expand a little for me please. Where exactly whould
i put the sub? And hw should i call the sub.
Thanx sooo much.


Sandy wrote:
Try using a case statement:


Sub Test()
Select Case Range("A1").Value
Case 100 To 104
Range("B1").Value = 40
Case 105 To 109
Range("B1").Value = 44
Case 110 To 114
Range("B1").Value = 47
Case Is = 115
Range("B1").Value = 50
End Select
End Sub

Sandy
amatuer wrote:
Hi, could sumone pls help me with a nested if statement...
I want to assign a number to a cell depending on wat the contents of
another cell is.

eg: 100 - 104 assign 40
105-109 assign 44
110-114 assign 47
115+ assign 50

this is 1 if statement, id like to also add anothr nested if statement
to that same cell...

any suggestion? Thanx in advance


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default If..statement

Thnx alot, i will try it out.

Sandy wrote:
If you weren't looking for a macro you could use this if function in a
cell(change A1 to what ever reference you'd like):

=IF(AND(A1=100,A1<=104),40,IF(AND(A1=105,A1<=109 ),44,IF(AND(A1=110,A1<=114),47,IF(A1=115,50,"Not hing"))))

If you want to use the macro:

open VBE (Alt +F11)
Click insert == Module paste the formula in the window.
To run click Tools == macro == marcos and highlight "Test" and click
play.

You'll need to change the ranges to the cell you want to change. If
you're not that well versed in VBA code I would recommend using the
formula instead

Sandy

amatuer wrote:
Hi Sandy, could you expand a little for me please. Where exactly whould
i put the sub? And hw should i call the sub.
Thanx sooo much.


Sandy wrote:
Try using a case statement:


Sub Test()
Select Case Range("A1").Value
Case 100 To 104
Range("B1").Value = 40
Case 105 To 109
Range("B1").Value = 44
Case 110 To 114
Range("B1").Value = 47
Case Is = 115
Range("B1").Value = 50
End Select
End Sub

Sandy
amatuer wrote:
Hi, could sumone pls help me with a nested if statement...
I want to assign a number to a cell depending on wat the contents of
another cell is.

eg: 100 - 104 assign 40
105-109 assign 44
110-114 assign 47
115+ assign 50

this is 1 if statement, id like to also add anothr nested if statement
to that same cell...

any suggestion? Thanx in advance




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
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 08:39 PM


All times are GMT +1. The time now is 03:03 AM.

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"