I have a worksheet where the rows are dynamic. in several columns, I have VBA to calculate the sum of the dynamic range.
The code works, and is as follows:
I now need to use that sum in another computation but do not know how to reference the cell in the formula. The data begins in Row 17 of the worksheet and the sum is in the last row of Column N.
I am a newbie to VBA code and use a lot of code suggestions from this site (such as the code cited above). This seems relatively simply but my efforts to date have not worked. Any help would be appreciated.
The code works, and is as follows:
Code:
Sub AutoSumTargetUrban()
Const SourceRange = "N:N"
Dim NumRange As Range, formulaCell As Range
Dim SumAddr As String
Dim c As Long
For Each NumRange In Columns(SourceRange).SpecialCells(xlConstants, xlNumbers).Areas
SumAddr = NumRange.Address(False, False)
Set formulaCell = NumRange.Offset(NumRange.Count, 0).Resize(1, 1)
formulaCell.Formula = "=SUM(" & SumAddr & ")"
c = NumRange.Count
Next NumRange
End Sub
I now need to use that sum in another computation but do not know how to reference the cell in the formula. The data begins in Row 17 of the worksheet and the sum is in the last row of Column N.
I am a newbie to VBA code and use a lot of code suggestions from this site (such as the code cited above). This seems relatively simply but my efforts to date have not worked. Any help would be appreciated.