Reputation: 25
I'm getting a run-time error while trying to calculate a common excel formula in VBA. Here's the part of the code that seems to have problems:
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("F4").Formula = "=IF(AND(C5=0;D5=0;E5=0);B5;IF(AND(C5=0;OR(D5<>0;E5<>0));B5;0))"
.Range("F4").Copy
With .Range("F5:F" & LastRow)
.PasteSpecial Paste:=8
.PasteSpecial Paste:=xlPasteFormulas
.PasteSpecial Paste:=xlPasteFormats
End With
End With
I'think there's simply something wrong in writing the formula using the correct VBA syntax, since if i just substitute with "=2+2" it works.
Upvotes: 1
Views: 99
Reputation: 4984
Replace Semicolon
with Comma
"=IF(AND(C5=0,D5=0,E5=0),B5,IF(AND(C5=0,OR(D5<>0,E5<>0)),B5,0))"
Upvotes: 1