PDA

View Full Version : Questions about conditions in excel function.



thanhvanchi
12-10-2016, 12:04 AM
Hello everyone!


Please help configure out this code. If the first code condition are OK the 3Spring will display in the S448 address(cell),
but if the first code are not satisfied. The second condition will
applied in the same address.

If sh1.Range("S448") = "N" Or sh1.Range("S448") = "ONT" Or sh1.Range("S448") = "PON" Then b = "3Spring"
Else: sh1.Range("S448") = "Nest3" Then b = "4Spring"


Thank's a lot!

onlyadrafter
12-10-2016, 01:50 AM
Hello,

does this solve it?


If sh1.Range("S448") = "N" Or sh1.Range("S448") = "ONT" Or sh1.Range("S448") = "PON" Then
b = "3Spring"
Else
If sh1.Range("S448") = "Nest3" Then b = "4Spring"
End If

You may want to look into SELECT CASE

Paul_Hossler
12-10-2016, 07:14 PM
Maybe something like this





Select Case sh1.Range("S448")
Case "N", "ONT", "PON"
b = "3Spring"
Case "Nest3"
b = "4Spring"
End Select

SamT
12-11-2016, 10:46 AM
Change "Else:" to "ElseIf"