#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default IF sum help

I am trying to add more than one IF and cannot for love nor money,
One sheet called positions where i enter details of positions placed. i will
enter 1 in a cell i want it to be 150 in another, if i enter 2 i want it to
be 100 etc
Hope you can help,
k1ngy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,118
Default IF sum help

This structure works if there will only be a few alternatives:
=IF(A1=1,150,IF(A1=2,100,"not 1 or 2"))

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"k1ngy" wrote in message
...
I am trying to add more than one IF and cannot for love nor money,
One sheet called positions where i enter details of positions placed. i
will
enter 1 in a cell i want it to be 150 in another, if i enter 2 i want it
to
be 100 etc
Hope you can help,
k1ngy




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default IF sum help

On Mar 15, 5:12 pm, "Ron Coderre"
wrote:
This structure works if there will only be a few alternatives:
=IF(A1=1,150,IF(A1=2,100,"not 1 or 2"))

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"k1ngy" wrote in message

...

I am trying to add more than one IF and cannot for love nor money,
One sheet called positions where i enter details of positions placed. i
will
enter 1 in a cell i want it to be 150 in another, if i enter 2 i want it
to
be 100 etc
Hope you can help,
k1ngy



You can also use this format:

......
Dim varCellValue As Variant
varCellValue = Cells(1, 1).Value

Select Case varCellValue
Case 1:
Cells(1, 2).Value = 150
Case 2:
Cells(1, 2).Value = 100
Case Is 2:
Cells(1, 2).Value = "Hi"
End Select
.......

It's a nice compact, easy-to-follow way to avoid a huge string of
nested IF statements (like below)

Nested IFs:

.....
Dim varCellValue As Variant
varCellValue = Cells(1, 1).Value

If varCellValue = 1 then
cells(1,2).value = 150
elseif varCellValue =2 then
cells(1,2).value=100
else
cells(1,2).value = "Hi"
end if


HTH

Chris
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default IF sum help

Thanks for replies,
I have 23 alternatives! will the below still work they are
1=150,2=100,3=80,4=70,5=60,6=50,7=40,8=30,9=20,10= 10,11=0,12=0,13=0,14=0,15=0,16=0,17=0,18=0,19=0,20 =0,21=0,22=0,DNF=0
Thanks,

"Ron Coderre" wrote:

This structure works if there will only be a few alternatives:
=IF(A1=1,150,IF(A1=2,100,"not 1 or 2"))

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"k1ngy" wrote in message
...
I am trying to add more than one IF and cannot for love nor money,
One sheet called positions where i enter details of positions placed. i
will
enter 1 in a cell i want it to be 150 in another, if i enter 2 i want it
to
be 100 etc
Hope you can help,
k1ngy





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default IF sum help

Thanks for your help i have done it now,
k1ngy

"k1ngy" wrote:

Thanks for replies,
I have 23 alternatives! will the below still work they are
1=150,2=100,3=80,4=70,5=60,6=50,7=40,8=30,9=20,10= 10,11=0,12=0,13=0,14=0,15=0,16=0,17=0,18=0,19=0,20 =0,21=0,22=0,DNF=0
Thanks,

"Ron Coderre" wrote:

This structure works if there will only be a few alternatives:
=IF(A1=1,150,IF(A1=2,100,"not 1 or 2"))

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"k1ngy" wrote in message
...
I am trying to add more than one IF and cannot for love nor money,
One sheet called positions where i enter details of positions placed. i
will
enter 1 in a cell i want it to be 150 in another, if i enter 2 i want it
to
be 100 etc
Hope you can help,
k1ngy





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



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

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"