Dim rng As Range
...
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Set rng = Selection
ActiveCell.Offset(0, 1).FormulaR1C1 = "=SUM(" & rng.Address & ")"
...
Above is the part of my code I'm having troubles with.
As you see, I'm having a selection and I want a =sum formula based on the selection, next to it.
It gives me the runtime error 1004, Application-defined or object-defined error, and marks the last line.
I thought that adding .Address to my range-variable would do the trick, but after some searching and other tries I realise I don't know what little tweak is needed to do this.
In the end it will be part of a loop, but that shouldn't be a problem as soon as this is fixed.
Kind regards.
Bookmarks