I need this formula:
=IF(J2="ACQ_PCT",P2,(IF(J2="AGP_PCT",P2,IF(J2="AWP_PCT",P2,IF(J2="MAC_PCT",P2,IF(J2="SUB_PCT",P2,""))))))
to paste from F2 to the the last row in F and the cells are blank until the formula is pasted (and possibly as seen by the formula blank still after). Columns A thru E are filled completely until the end of the data if that helps for an auto fill code. I actually have 3 formulas that this will be used for in columns F, G and H; all the formulas are different. This is for a macro that will be executed with Ctrl + W, and format a large set of data. (I only include all of this extra information because I am not sure if it helps)
I tried:
Sub test()
Dim lastRow As Long
With Sheets("Sheet1")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
With .Range("F2:F" & lastRow)
.Formula = "=IF(J3="ACQ_PCT",P3,(IF(J3="AGP_PCT",P3,IF(J3="AWP_PCT",P3,IF(J3="MAC_PCT",P3,IF(J3="SUB_PCT",P3,""))))))"
.Value = .Value
End With
End With
End Sub
But it see's the " within the IF function and thinks that its the end of the statement...not sure how else to write the IF statement to make it not think this.
Thank you guys. I am still very new to VBA, I have always just written formulas, but I am trying to teach myself the ins and outs of VBA now so any explainations of my errors will be appreciated.
=IF(J2="ACQ_PCT",P2,(IF(J2="AGP_PCT",P2,IF(J2="AWP_PCT",P2,IF(J2="MAC_PCT",P2,IF(J2="SUB_PCT",P2,""))))))
to paste from F2 to the the last row in F and the cells are blank until the formula is pasted (and possibly as seen by the formula blank still after). Columns A thru E are filled completely until the end of the data if that helps for an auto fill code. I actually have 3 formulas that this will be used for in columns F, G and H; all the formulas are different. This is for a macro that will be executed with Ctrl + W, and format a large set of data. (I only include all of this extra information because I am not sure if it helps)
I tried:
Sub test()
Dim lastRow As Long
With Sheets("Sheet1")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
With .Range("F2:F" & lastRow)
.Formula = "=IF(J3="ACQ_PCT",P3,(IF(J3="AGP_PCT",P3,IF(J3="AWP_PCT",P3,IF(J3="MAC_PCT",P3,IF(J3="SUB_PCT",P3,""))))))"
.Value = .Value
End With
End With
End Sub
But it see's the " within the IF function and thinks that its the end of the statement...not sure how else to write the IF statement to make it not think this.
Thank you guys. I am still very new to VBA, I have always just written formulas, but I am trying to teach myself the ins and outs of VBA now so any explainations of my errors will be appreciated.