VBA code in excel problem

  • Thread starter Thread starter Jacek Polar
  • Start date Start date
J

Jacek Polar

Hi,

I'd like to fill some numbers of Excel 2000 cells with a formula,
so I wrote code in VBA (see below):

Cells(r,c).Formula = "=VLOOKUP($A4;[dane.xls]
where r - row, c - col, $A4 - cell with searching string

When I run VBA code I see error message:
Run-time error 1004:
Application-defined or object-defined error.

When I paste the formula into cell or type it everything is ok,
only VBA code makes problem.
What could be wrong, how should I solve the problem.
Thanks in advance.

Regards,
Jacek
 
Of course I cut my code, sorry:
Cells(r,c).Formula = "=VLOOKUP($A4;[dane.xls]Sheet1!$A$2:$B$5;2;FALSE)"

Regards,
Jacek
 
Hi Jacek

This works for me if I replace the semi-colons with commas which is what
is required by my settings:

Cells(r, c).Formula = "=VLOOKUP($A4,[dane.xls]Sheet1!$A$2:$B$5,2,FALSE)"

If you can paste the formula manually and it works then it would seem
your language and international settings require semi-colons but it
might be worth trying it this way just to see what result you get.

Hope this helps
Rowan

Jacek said:
Of course I cut my code, sorry:
Cells(r,c).Formula = "=VLOOKUP($A4;[dane.xls]Sheet1!$A$2:$B$5;2;FALSE)"

Regards,
Jacek

Hi,

I'd like to fill some numbers of Excel 2000 cells with a formula,
so I wrote code in VBA (see below):

Cells(r,c).Formula = "=VLOOKUP($A4;[dane.xls]
where r - row, c - col, $A4 - cell with searching string

When I run VBA code I see error message:
Run-time error 1004:
Application-defined or object-defined error.

When I paste the formula into cell or type it everything is ok,
only VBA code makes problem.
What could be wrong, how should I solve the problem.
Thanks in advance.

Regards,
Jacek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top