I found the first code below, created by mirabeau, and it works great. It's basically the code to do the same as Autosum. But what I need to do is insert this into my code that I'm working on into a specific cell. In my code, the line that reads:
Range("s" & R.Row).Value = 0
I need the value to be the result of the autosum code.
If anyone has any ideas, It would be much appreciated. Thanks.
mirabeau's auto sum code:
my code:
Range("s" & R.Row).Value = 0
I need the value to be the result of the autosum code.
If anyone has any ideas, It would be much appreciated. Thanks.
mirabeau's auto sum code:
Code:
Sub replicate_alt_equal()
Dim a As Range, b, tr As Range
With ActiveCell
On Error Resume Next
Set a = Cells(1, .Column).Resize(.Row - 1)
b = a
a.SpecialCells(2, 2) = ""
If .End(3).Offset(-1) = "" Then
Set tr = .End(3)
Else
Set tr = .End(3).End(3)
End If
.Formula = _
"=Sum(" & .End(3).Address(0, 0) & ":" & tr.Address(0, 0) & ")"
Range(.Offset(-1), tr).Copy
a.Value = b
End With
End Sub
my code:
Code:
Sub inset2rows()
'
' inset2rows Macro
'
'
Range(ActiveCell.Row & ":" & ActiveCell.Row).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(-1, 0).Select
Selection.Resize(1, 13).Select
Set Rng = Selection
Selection.Copy
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Selection.Resize(1, 19).Select
Set Rng = Selection
For Each R In Rng
Range("s" & R.Row).Value = 0
Application.CutCopyMode = False
Next R
End Sub