![]() |
|
|
Thread Tools | Display Modes |
#2
|
|||
|
|||
![]()
Try this, seems to work
Code:
Sub AutoSum() 'https://stackoverflow.com/questions/24047824/vba-excel-loop-assistance Dim Area As Range, MyColumn As String, startNum As String, SumAddr As String Dim i As Long For i = 2 To 9 'Columns B to E For Each Area In Columns(i).SpecialCells(xlConstants, xlNumbers).Areas If Area.Count <= 1 Then GoTo Skip startNum = Area.Resize(1, 1).Address(False, False) SumAddr = Area.Offset(1, 0).Resize(Area.Count - 1, 1).Address(False, False) Area.Offset(Area.Count, 0).Resize(1, 1).Formula = "=" & startNum & "-SUM(" & SumAddr & ")" Area.Offset(Area.Count, 0).Resize(1, 1).Font.Color = vbRed Skip: Next Area Next i End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
innkeeper9 | Excel | 5 | 08-30-2016 04:43 PM |
Subtract value from one cell into another | otuatail | Excel | 3 | 02-01-2016 03:21 AM |
Mouseover cell to indicate mouse pointer location based on Specific Row/Column values | bolandk | Excel | 1 | 05-15-2014 08:22 AM |
Summing Non Contiguous Cells in a Row or Column | Joe Ottenhof | Excel | 4 | 12-19-2012 04:13 AM |
From a particular cell till the end of the same column | tinfanide | Excel | 3 | 08-10-2011 05:09 AM |