ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Formula - Error 1004 - Bug? Mistake? (https://www.excelbanter.com/excel-programming/285456-excel-formula-error-1004-bug-mistake.html)

Markus Wilthaner

Excel Formula - Error 1004 - Bug? Mistake?
 
Hello,

I have a worksheet and the following line of code:
Me.Range("G11").Formula = "=SUMIF(A1;1;A3:A6)"

Excel says: 1004 Application error

What am I doing wrong? If I enter the exact same string as a formula,
everything works fine. Help! :)


Markus

Tom Ogilvy

Excel Formula - Error 1004 - Bug? Mistake?
 
Either change the semi colons (;) to commas or use FormulaLocal rather than
Formula (assuming your list separator is set to semicolon).

However, I don't thing the formula will produce what you want.

Maybe you want an if statement
=If(A1=1,Sum(A3:A6),0)

--
Regards,
Tom Ogilvy

"Markus Wilthaner" wrote in message
m...
Hello,

I have a worksheet and the following line of code:
Me.Range("G11").Formula = "=SUMIF(A1;1;A3:A6)"

Excel says: 1004 Application error

What am I doing wrong? If I enter the exact same string as a formula,
everything works fine. Help! :)


Markus




Markus Wilthaner

Excel Formula - Error 1004 - Bug? Mistake?
 
"Tom Ogilvy" wrote:
Either change the semi colons (;) to commas or use FormulaLocal rather than
Formula (assuming your list separator is set to semicolon).


First, thanks for helping me out.
You were right, the semi colons are my list separator. Excel is smart
and replaces commas in the from-code-formulas with the semicolons.

I tried the same script on my Excel 2003 computer and it filled in the
formulas. However, all I get is an "Name" Error. When I edit the cell
(F2) and press enter without changing anything, it works! Odd....

Using "LocalFormula" causes my Excel 2003 to give me that 1004
Application error. :(

What I was trying to accomplish is to count the occurence of a giving
string in a number of cells, using SUMIF(<Range, <GivenString).

Thank you,


Markus

Tom Ogilvy

Excel Formula - Error 1004 - Bug? Mistake?
 
Using "LocalFormula"

it isn't localformula, it is formulalocal

when you use formulalocal, the formula should be written as you would enter
it in a cell (including non-english works/names if that is how you work in
your spreadsheet).

--
Regards,
Tom Ogilvy

Markus Wilthaner wrote in message
m...
"Tom Ogilvy" wrote:
Either change the semi colons (;) to commas or use FormulaLocal rather

than
Formula (assuming your list separator is set to semicolon).


First, thanks for helping me out.
You were right, the semi colons are my list separator. Excel is smart
and replaces commas in the from-code-formulas with the semicolons.

I tried the same script on my Excel 2003 computer and it filled in the
formulas. However, all I get is an "Name" Error. When I edit the cell
(F2) and press enter without changing anything, it works! Odd....

Using "LocalFormula" causes my Excel 2003 to give me that 1004
Application error. :(

What I was trying to accomplish is to count the occurence of a giving
string in a number of cells, using SUMIF(<Range, <GivenString).

Thank you,


Markus





All times are GMT +1. The time now is 04:15 PM.

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