memoorefield
New Member
- Joined
- Jun 17, 2015
- Messages
- 14
I have a macro that sums column C with varying numbers of rows. It works great with no problems. I would like to also have the macro take that sum and divide it by the value in cell M and paste the new value in cell D. My current formula is below.
Const SourceRange = "C"
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
Const SourceRange = "C"
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