Error when inserting formula into excel via VBA

Kronix

Registered User.
Local time
Today, 22:31
Joined
Nov 2, 2017
Messages
102
So I insert "=SUMME(F2:F254)" into a cell in Excel. When I go to Excel it shows #NAME? in the cell instead of the sum. But when I click on the cell to edit it and then leave the cell without changing anything, the formula suddenly works and it shows the sum. How do I make the formula work from the beginning?
 
So how are you inserting it? Code please.
 
I tried

Code:
xlws.Cells(reccount + 2, "F").Formula = "=SUM(F2:F254)"

and

Code:
xlws.Cells(reccount + 2, "F").Value = "=SUM(F2:F254)"

Do I need some kind of formatting to tell it that the string should be treated as a formula? You'd think using the Formula attribute would handle things by itself.
 
Last edited:
Nevermind, I found the problem. I was using the foreign language version of the SUM function when assigning the string in VBA code. It keeps turning up that VBA code always requires English versions of functions, which is quite frustrating when even SQL functions must be written in the foreign language.
 
Posts crossed in the ether!

Glad you solved it.
 

Users who are viewing this thread

Back
Top Bottom