The Godfather
New Member
- Joined
- Jul 22, 2011
- Messages
- 30
- Office Version
- 365
- 2016
- Platform
- Windows
Hi,
I have the following formula below, where a single task is done for 10 different rows (stars with row 12 and ends with row 21).
I typed the code for each row. Is it possible to do it just with a single code? (I tried ranging the cells - ie ranging "I12:J12"- but it crashed)
I have the following formula below, where a single task is done for 10 different rows (stars with row 12 and ends with row 21).
I typed the code for each row. Is it possible to do it just with a single code? (I tried ranging the cells - ie ranging "I12:J12"- but it crashed)
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("I12"), Range(Target.Address)) Is Nothing Then
Range("J12").Value = ""
Range("K12").Value = ""
End If
If Not Intersect(Range("I13"), Range(Target.Address)) Is Nothing Then
Range("J13").Value = ""
Range("K13").Value = ""
End If
If Not Intersect(Range("I14"), Range(Target.Address)) Is Nothing Then
Range("J14").Value = ""
Range("K14").Value = ""
End If
If Not Intersect(Range("I15"), Range(Target.Address)) Is Nothing Then
Range("J15").Value = ""
Range("K15").Value = ""
End If
If Not Intersect(Range("I16"), Range(Target.Address)) Is Nothing Then
Range("J16").Value = ""
Range("K16").Value = ""
End If
If Not Intersect(Range("I17"), Range(Target.Address)) Is Nothing Then
Range("J17").Value = ""
Range("K17").Value = ""
End If
If Not Intersect(Range("I18"), Range(Target.Address)) Is Nothing Then
Range("J18").Value = ""
Range("K18").Value = ""
End If
If Not Intersect(Range("I19"), Range(Target.Address)) Is Nothing Then
Range("J19").Value = ""
Range("K19").Value = ""
End If
If Not Intersect(Range("I20"), Range(Target.Address)) Is Nothing Then
Range("J20").Value = ""
Range("K20").Value = ""
End If
If Not Intersect(Range("I21"), Range(Target.Address)) Is Nothing Then
Range("J21").Value = ""
Range("K21").Value = ""
End If
End Sub