Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Fill formula from VBA

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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Fill formula from VBA

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?



  #4   Report Post  
Posted to microsoft.public.excel.programming
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?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Fill formula from VBA

Tom,

Thanks! That realy helps!
I was confused because in Excel the formule is shown with semicolons, but
from VBA I have to enter them using comma's.

Archie

"Tom Ogilvy" wrote in message
...
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?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Fill formula from VBA

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
  #7   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill Formula please palups Excel Worksheet Functions 5 November 12th 09 08:27 AM
formula fill down Pezcore Excel Discussion (Misc queries) 4 May 10th 08 06:17 PM
Formula Fill help Josh O. Excel Worksheet Functions 1 May 12th 06 09:46 PM
Fill Down formula Help Please singlgl1 Excel Discussion (Misc queries) 6 October 24th 05 08:22 PM
Help with formula fill down comotoman Excel Discussion (Misc queries) 4 October 3rd 05 09:46 PM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"