IF sum help

  • Thread starter Thread starter k1ngy
  • Start date Start date
K

k1ngy

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
 
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)
 
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)


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
 
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,
 
Thanks for your help i have done it now,
k1ngy

k1ngy said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top