Thread: IF sum help
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
cht13er cht13er is offline
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