Hello All,
Please help me to find the Sum for each cell in below in VBA code. Please take a look at sample attached for more detail.
Regards,
tt3
Hello All,
Please help me to find the Sum for each cell in below in VBA code. Please take a look at sample attached for more detail.
Regards,
tt3
I think that this will do what you want
Sub test() Dim oneArea As Range Dim LastPair As Range, PairFtn As String For Each oneArea In Range("AG:AG").SpecialCells(xlCellTypeConstants, xlNumbers).Areas With oneArea.Cells(1, 1).Offset(-1, 0) If .Offset(-1, 0).Value = vbNullString Then If Not LastPair Is Nothing Then LastPair.FormulaR1C1 = PairFtn End If Set LastPair = .Offset(-1, 0) PairFtn = "=" & .Address(True, True, xlR1C1) Else PairFtn = PairFtn & "+" & .Address(True, True, xlR1C1) End If .FormulaR1C1 = "=SUM(" & oneArea.Address(True, True, xlR1C1) & ")" End With Next oneArea If Not LastPair Is Nothing Then LastPair.FormulaR1C1 = PairFtn End If End Sub
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Hi Mikerickson,
The code is perfect and is it possible to do another code in tab "Scenario1"? Thank you very much for your help.
Regards,
tt3
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks