I am a true beginner with editing code, but I have a workbook that has many repeating formulas and I got to a point when building the file that it no longer works. In trying to resolve the issue, what I am assuming is that I need to break up the following code into smaller pieces:
-------------------------------------------------------------------
Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$6" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$7" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$8" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$9" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
...and this code goes on and on and then moves to another column, with the same formula, etc.
----------------------------------------
Is it possible to revise the Target.Address to a range? (i.e. $K$9:$K$25)
I have tried to format the code into smaller increments, but then I get other errors.
Any help is appreciated.
-------------------------------------------------------------------
Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$6" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$7" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$8" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$K$9" Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Offset(, 1) = Target.Offset(, 1) + Target.Value
Application.EnableEvents = True
End If
End If
...and this code goes on and on and then moves to another column, with the same formula, etc.
----------------------------------------
Is it possible to revise the Target.Address to a range? (i.e. $K$9:$K$25)
I have tried to format the code into smaller increments, but then I get other errors.
Any help is appreciated.