Hi Guys!
I'm just trying to make a for loop that adds a formula to a cell and I keep running an error on that line so I think I typed it in wrong, and I'm pretty sure it has to do with some quotation marks I used, but I've used VBA to create a formula in a sheet before so if someone could just look it over and let me know where I messed up and why that would be greatly appreciated. Thanks!
This is the line:
This is an example of what the formula should look like after:
I'm just trying to make a for loop that adds a formula to a cell and I keep running an error on that line so I think I typed it in wrong, and I'm pretty sure it has to do with some quotation marks I used, but I've used VBA to create a formula in a sheet before so if someone could just look it over and let me know where I messed up and why that would be greatly appreciated. Thanks!
This is the line:
VBA Code:
Worksheets(1).Range("J" & CStr(Row)).Formula = "=IF(OR(C" & CStr(Row) & "= """",(C" & CStr(Row) & "-I" & CStr(Row) & ")=0, ""NA"","" SUM(E" & CStr(Row) & "*0.1*1,F" & CStr(Row) & "*0.2*2,G" & CStr(Row) & "0.3*3, H" & CStr(Row) & "0.4*4)/SUM(E" & CStr(Row) & "*0.1, F" & CStr(Row) & "*0.2, G" & CStr(Row) & "*0.3, H" & CStr(Row) & "*0.4))"
This is an example of what the formula should look like after:
VBA Code:
=IF(OR(C17="", (C17-I17)=0), "NA", SUM(E17*0.1*1,F17*0.2*2,G17*0.3*3,H17*0.4*4)/SUM(E17*0.1,F17*0.2,G17*0.3,H17*0.4))