If Then
To enter a formula in F2 manually, you can nest up to 7 IF statements (in
Excel 2003 & earlier) like this:
=IF(A2=1,B2*12*0.67,IF(A2=2,B2*12,IF(A2=3,750,0)))
To populate F2 using VBA, you could use something like:
Sub Populate_F2()
Select Case Range("A2").Value
Case 1
Range("F2").Formula = "=B2*12*.67"
Case 2
Range("F2").Formula = "=B2*12"
Case 3
Range("F2").Formula = "=750"
Case Else
'do nothing
End Select
End Sub
Hutch
"Jamesbfagan" wrote:
That was really helpful thank you.
If I want it to be able to read multiple values such as if A2 =1 then
F2=B2*12*0.67 or if A2= 2 then F2=B2*12 or if A2=3 then F2=750 how would I do
that?
Thanks Again
"Tom Hutchins" wrote:
To enter this manually, enter this in F2:
=IF(A2=1,B2*12*0.67,0)
You didn't say what F2 should contain if A2 is not 1, so I just put 0.
To do this using VBA:
If Range("A2").Value = 1 Then
Range("F2").Formula = "=B2*12*.67"
End If
The above code could be part of a VBA procedure.
Hope this helps,
Hutch
"Jamesbfagan" wrote:
How would I program the following formula?
If A2=1 Then F2=B2*12*.67
|