score,
Updated code (see attached workbook):
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngToCheck As Range: Set rngToCheck = Me.Range("G16:K25,O16:S25,G32:K41,O32:S41")
If Not Intersect(rngToCheck, Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim grp As Range, rngDest As Range
Dim RowIndex As Integer, AdjustIndex As Integer
For Each grp In rngToCheck.Areas
If Not Intersect(Target, grp) Is Nothing Then
Select Case Left(grp.Address, InStr(grp.Address, ":") - 1)
Case "$G$16": AdjustIndex = 0
Case "$O$16": AdjustIndex = 10
Case "$G$32": AdjustIndex = 20
Case "$O$32": AdjustIndex = 30
End Select
For RowIndex = grp.Row To grp.Row + grp.Rows.Count - 1
If Not Intersect(Range(Cells(RowIndex, grp.Column), Cells(RowIndex, grp.Column + grp.Columns.Count - 1)), Target) Is Nothing _
And IsNumeric(Cells(RowIndex, grp.Column + grp.Columns.Count).Value) Then
Set rngDest = Me.[X9].Offset(RowIndex - grp.Row + AdjustIndex, 0)
rngDest.Value = rngDest.Value + Cells(RowIndex, grp.Column + grp.Columns.Count).Value
End If
Next RowIndex
End If
Next grp
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Hope that helps,
~tigeravatar
Bookmarks