PDA

View Full Version : Solved: FormulaR1C1 giving error 1004



SeanJ
11-11-2008, 08:43 AM
I need help on this formula please see below.

This is a formula for a cell =IF((AND(ISBLANK(A29),ISBLANK(A30),ISBLANK(A31))),"",1) I want us it in VBA. I have other formula like this one bjut more in depth. They all work from the cells but I am having issues converting to VBA. I keep getting error 1004, and I don't know why

Function Setting_voucher_count_formulas(FndString As String)
If FndString = "happy" Then
x = 28
ElseIf FndString = "sad" Then
x = 38
ElseIf FndString = "not yet" Then
x = 48
End If
numRowcount = x
'=IF((AND(ISBLANK(A29),ISBLANK(A30),ISBLANK(A31))),"",1)

ws.Cells(numRowcount, 4).FormulaR1C1 = "=IF((AND(ISBLANK(R[-1]C),ISBLANK(R[-2]C),ISBLANK(R[-3]C))),"",1)"

End Function

Bob Phillips
11-11-2008, 09:09 AM
Two things.

When you use quotes in a VBA formula, you need to double them up, """"

And the worksheet variable ws is not defined so it has no value.

SeanJ
11-11-2008, 09:12 AM
I will give it a try.

Bob Phillips
11-11-2008, 09:21 AM
BTW, you seem to be moving riows up instead of down as in your example. Should it be



ws.Cells(numRowcount, 4).FormulaR1C1 = "=IF(AND(ISBLANK(R[+1]C),ISBLANK(R[+2]C),ISBLANK(R[+3]C)),"""",1)"