View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 1,311
Default Run Time errot 1004, with formula

How are these defined?

pbeyeydesc
pbeydescchg
pbeyorigtrdesc
CFPBEY
RT
intUniqueTrDesc
StartRow
intNumOfTrDesc
HdrRow

Regards,
Paul

"mikeb" wrote in message
...
I'm getting this common error with this code, it looks as if the formula
as
causing it, tried assigning formula to a string and directly, no change,
let
me know if you need more info, thanks in advance

Sheets(CFPBEY).Select
Range("E11:E20000").ClearContents
ColLoc1 = pbeyeydesc - pbeydescchg
ColLoc2 = pbeyeydesc - pbeyorigtrdesc
Dim test As String
test = "=IF(RC[-" & ColLoc1 & "]<0,VLOOKUP(RC[-" & ColLoc1 & "],'" & RT &
"'!$A$5:$B$" & _
intUniqueTrDesc & ",2,FALSE),VLOOKUP(RC[-" & ColLoc2 & "],'" & RT &
"'!$A$5:$B$" & _
intUniqueTrDesc & ",2,FALSE))"

Sheets(CFPBEY).Range(Cells(StartRow, pbeyeydesc), Cells(intNumOfTrDesc +
HdrRow, pbeyeydesc)).Formula = test

'_
' "=IF(RC[-" & ColLoc1 & "]<0,VLOOKUP(RC[-" & ColLoc1 & "],'" & RT &
"'!$A$5:$B$" & _
' intUniqueTrDesc & ",2,FALSE),VLOOKUP(RC[-" & ColLoc2 & "],'" & RT &
"'!$A$5:$B$" & _
' intUniqueTrDesc & ",2,FALSE))"