Here is the code:
Sub INSERTSUM()
Dim x As Integer
Dim Var1 As Range
Dim Var2 As Range
Dim sText As String
Dim oper As String
Dim bottom As Long
Dim Btmcheck As Long
For x = 1 To 10
Set Var1 = Selection
Set Var2 = Var1.End(xlDown)
Let bottom = 65536
sText = Range(Var1, Var2).Address
oper = "=Sum(" & sText & ")"
Var2.Offset(1, 0).Value = oper
Selection.End(xlDown).Select
Let Btmcheck = Selection.Row
If Btmcheck = bottom Then
Exit For
End If
Selection.End(xlDown).Select
Let Btmcheck = Selection.Row
If Btmcheck = bottom Then
Exit For
End If
Next x
Range("a1").Select
End Sub
This code works fine on the following collumn of data:
222
333
333
333
444
555
666
But does not work properly on the followig collumn of data:
222
333
333
555
666
It will have a problem when there are not at least 2 numeric valus located in adjacent vertical cells. I either need it to skip one row entries or place the sum right under them, and continue on.
Thanks
Mike