Hello,
I am trying to assignt the following formula to a cell, but keep getting above error on the last line...Cells(i, 5).Formula = strFormula. I've tried with and without Formula property and it does not work. Hard coding values or a simple "=a1+b1" works, but for some reason does not like the strFormula variable.
Any help is most appreciated.
With Sheets("Emdeon Inc_Post eRX (2)")
FinalRow = .Cells(Rows.Count, 1).End(xlUp).Row
'For iShtCount = 1 To 3
'shtName = "Emdeon Inc_Prior to eRX"
For i = 8 To FinalRow
If .Cells(i, 1) <> "" And Right(.Cells(i, 1), 6) <> "Total" Then AcctFamil = .Cells(i, 1)
If .Cells(i, 2) <> "" And Right(.Cells(i, 2), 6) <> "Total" Then AcctCat = .Cells(i, 2)
If .Cells(i, 1) <> "" And Right(.Cells(i, 3), 6) <> "Total" Then Rollup2 = .Cells(i, 3)
If Cells(i, 4) <> "" Then AcctName = Cells(i, 4).Address
strFormula = "GETPIVOTDATA(' JUL-09','Emdeon Inc_Prior to eRX'!$A$6,'ACCT_FAMIL'," & "'" & AcctFamil & "'" & ",'ACCT_CAT'," & "'" & AcctCat & _
"'" & "'ROLLUP2'," & "'" & Rollup2 & "'" & ",'ACCT_NAME'," & "'" & AcctName & "'" & ")),0,"
strFormula = "=IF(ISERROR(" & strFormula & Left(strFormula & strFormula, Len(strFormula) - 3)
.Cells(i, 5).Formula = strFormula 'Change column to reflect proper spreadsheet source
I am trying to assignt the following formula to a cell, but keep getting above error on the last line...Cells(i, 5).Formula = strFormula. I've tried with and without Formula property and it does not work. Hard coding values or a simple "=a1+b1" works, but for some reason does not like the strFormula variable.
Any help is most appreciated.
With Sheets("Emdeon Inc_Post eRX (2)")
FinalRow = .Cells(Rows.Count, 1).End(xlUp).Row
'For iShtCount = 1 To 3
'shtName = "Emdeon Inc_Prior to eRX"
For i = 8 To FinalRow
If .Cells(i, 1) <> "" And Right(.Cells(i, 1), 6) <> "Total" Then AcctFamil = .Cells(i, 1)
If .Cells(i, 2) <> "" And Right(.Cells(i, 2), 6) <> "Total" Then AcctCat = .Cells(i, 2)
If .Cells(i, 1) <> "" And Right(.Cells(i, 3), 6) <> "Total" Then Rollup2 = .Cells(i, 3)
If Cells(i, 4) <> "" Then AcctName = Cells(i, 4).Address
strFormula = "GETPIVOTDATA(' JUL-09','Emdeon Inc_Prior to eRX'!$A$6,'ACCT_FAMIL'," & "'" & AcctFamil & "'" & ",'ACCT_CAT'," & "'" & AcctCat & _
"'" & "'ROLLUP2'," & "'" & Rollup2 & "'" & ",'ACCT_NAME'," & "'" & AcctName & "'" & ")),0,"
strFormula = "=IF(ISERROR(" & strFormula & Left(strFormula & strFormula, Len(strFormula) - 3)
.Cells(i, 5).Formula = strFormula 'Change column to reflect proper spreadsheet source