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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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