Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Then
How would I program the following formula?
If A2=1 Then F2=B2*12*.67 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Then
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Then
If you mean put this formula in F2 with VBA given a value of 1 in A2.
Sub EnterValueInF2() If Range("A2").value=1 then Range("F2").Formula= "=B2*12*0.67" End if End Sub Paul "Jamesbfagan" wrote in message ... How would I program the following formula? If A2=1 Then F2=B2*12*.67 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Then
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|