Applying code to multiple cells & rows

Bolter LAC

Board Regular
Joined
Aug 13, 2008
Messages
140
A forum member has kindly provided some code which works a treat. I need to apply it to multiple columns A through to F and cells 2 down to 36. How do I incorporate this into the code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Target.Count > 1 Then
If Target.Address = "$A$2" Then
If Target.Value = "X" Then Application.Goto ThisWorkbook.Sheets("Sheet2").Range("A2")
End If
End If
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  10/28/2020  9:51:02 PM  EDT
If Not Target.Count > 1 Then
If Target.Row = 1 Then MsgBox "Does not work on Row(1)": Exit Sub
If Target.Column < 7 And Target.Row < 37 Then
If Target.Value = "X" Then Application.Goto ThisWorkbook.Sheets("Sheet2").Range(Target.Address)
End If
End If
End Sub
 
Last edited:
Upvote 0
I added one little extra part. So use this script:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  10/28/2020  10:01:32 PM  EDT
If Not Target.Count > 1 Then
If Target.Row = 1 And Target.Column < 7 Then MsgBox "Does not work on Row(1)": Exit Sub
If Target.Column < 7 And Target.Row < 37 Then
If Target.Value = "X" Then Application.Goto ThisWorkbook.Sheets("Sheet2").Range(Target.Address)
End If
End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top