VBA to put a formula in cell producess unwanted structured reference

Bart47

New Member
Joined
Dec 18, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to put a sum formula in a cell. The formula has some variables and the result comes with an unwanted '@'

My code:
Dim rowbasis As Integer
rowbasis=Range("D1").Value
Range("M" & rowbasis + 1).Formula = "=som($M$5:M" & rowbasis & ")"


Given that D1 has the value 467, this gives in the cell M468 following:
=@ som($M$5:M467)

I don't want this @. What am I doing wrong?

Kind regards,
Bart
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hello and Welcome

I tried and it worked for me.

Try:
VBA Code:
Dim rowbasis As Integer
rowbasis = Range("D1").Value
Range("M" & rowbasis + 1).Formula = "=sum($M$5:$M$" & rowbasis & ")"
 
Upvote 0
Solution
No i change this : Range("M" & rowbasis + 1).Formula = "=som($M$5:M" & rowbasis & ")"
To this: Range("M" & rowbasis + 1).Formula = "=sum($M$5:$M$" & rowbasis & ")"

The right formula is SUM not SOM
 
Upvote 0
Hello and Welcome

I tried and it worked for me.

Try:
VBA Code:
Dim rowbasis As Integer
rowbasis = Range("D1").Value
Range("M" & rowbasis + 1).Formula = "=sum($M$5:$M$" & rowbasis & ")"
Works. THANK YOU!
My mistake: I accidently spelled the sum in my mother tongue (som). Since VBA only works in English it was interpreted as a structured reference.
I completeley missed the wrong spelling, but by watching your answer , I immediately saw it. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top