ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IF sum help (https://www.excelbanter.com/excel-programming/407738-if-sum-help.html)

k1ngy

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


Ron Coderre

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





cht13er

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

k1ngy

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






k1ngy

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







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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com