Excel 2002
I am trying to reference a range of cells using a variable and then put the sum of that range in another cell. Below is my code:
The line in blue is where I'm having trouble. Once the macro finishes and I look in cell L1772, all is says is =SUM(MRange). I've tried the formula as
MFormula = "=Sum(" & MRange & ") but get an error.
I can't figure out the correct syntax or if I'm even able to create this formula.
Once I figure out this formula, I'll need to add the variable to another formula.
FormulaR1C1 = "=SUM(R3C13:R[-2]C)" <--the original formula
FormulaR1C1 = "=SUM(R3C13:R[-2]C) + MRange" <--formula I'd like to end up with
Any help will be much appreciated!
I am trying to reference a range of cells using a variable and then put the sum of that range in another cell. Below is my code:
Code:
Dim Nett As Range
Dim MRange As Range
Dim MFormula As String
Set Nett = Cells.Find(what:="nett.", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Offset(1, 0)
Set MRange = Range(Nett, Selection.End(xlDown))
[COLOR=Blue]MFormula = "=Sum(MRange)"[/COLOR]
Range("L1772").FormulaR1C1 = MFormula
MFormula = "=Sum(" & MRange & ") but get an error.
I can't figure out the correct syntax or if I'm even able to create this formula.
Once I figure out this formula, I'll need to add the variable to another formula.
FormulaR1C1 = "=SUM(R3C13:R[-2]C)" <--the original formula
FormulaR1C1 = "=SUM(R3C13:R[-2]C) + MRange" <--formula I'd like to end up with
Any help will be much appreciated!