ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code in excel problem (https://www.excelbanter.com/excel-programming/341891-vba-code-excel-problem.html)

Jacek Polar

VBA code in excel problem
 
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





Jacek Polar

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

Regards,
Jacek

Użytkownik "Jacek Polar" napisał w wiadomości
...
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







Rowan Drummond[_3_]

VBA code in excel problem
 
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 Polar wrote:
Of course I cut my code, sorry:
Cells(r,c).Formula = "=VLOOKUP($A4;[dane.xls]Sheet1!$A$2:$B$5;2;FALSE)"

Regards,
Jacek

Użytkownik "Jacek Polar" napisał w wiadomości
...

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









All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com