View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Archie[_6_] Archie[_6_] is offline
external usenet poster
 
Posts: 4
Default Fill formula from VBA

Don,

I am using the first method to enter to formula and it fails.
This because of the reference to another Sheet.
Leaving this reference out solves the problem, but I need the reference
Entering the formula by hand solves the problem, but the formula has to
filled in on 6000 lines :(

"Don Guillett" wrote in message
...
If you want the formula
range("a2").formula="=yourformla"
if you want the result
range("a2")=application.vlookup(etc

--
Don Guillett
SalesAid Software

"Archie" wrote in message
...
Hi,

I try to enter a formula in a cell using VBA: =VLOOKUP($L2;'Sheet
2'!$A$2:$D$6000;2;FALSE)
This fails with a Run-time error '1004'
Entering this formula by hand works OK

When I remove the reference to 'Sheet 2' it all works OK:
=VLOOKUP($L2;$A$2:$D$6000;2;FALSE)

It looks like a bug to me (or a feature?)

How can I insert this formula refering to another sheet in a cell using
VBA?