View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Loading a formula from VB

Without testing...

You wrote your formula in A1 reference style--not R1C1 reference style.

ActiveCell.Formula = formula_str





Michael wrote:

I am attempting to load a formula from VB. I get an object defined error on
the final line of code below

Dim formula_str As String

Range(M4).Select

formula_str =
"=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))"
ActiveCell.FormulaR1C1 = formula_str


--

Dave Peterson