View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Fill formula from VBA

Yes, thanks for catching the typo.

--
Regards,
Tom Ogilvy


"Dave Peterson" wrote:

I think you meant:
Activecell.FormulaLocal
instead of
activecell.formular1c1



Tom Ogilvy wrote:

You need to enter the formula using US English conventions:

ActiveCell.Formula = "=VLOOKUP($L2,'Sheet 2'!$A$2:$D$6000,2,FALSE)"

this assumes that the name of the sheet is "Sheet 2" with a space and not
the default "Sheet2" without a space.

if you want to use semicolons (not recommended for VBA)

ActiveCell.FormulaR1C1 = "=VLOOKUP($L2;'Sheet 2'!$A$2:$D$6000;2;FALSE)"

and this assumes that the name of the function in your regional version is
VLOOKUP

--
Regards,
Tom Ogilvy

"Archie" wrote:

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?




--

Dave Peterson