How can I edit this to work on more than just one Cell?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,212
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
The code below is a stop for a protected sheet so the tabing doesn't go everywhere,
however it only works on column G,
how can I change it so it works on G:M?
thanks
Tony


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
LastR = Sheets("Weekly Data Input").Cells(Rows.Count, "F").End(xlUp).Row
    With Application
        If Target.Address = Range("G" & LastR).Address Then
            .OnKey "{TAB}", Me.CodeName & ".GoBack"
            .OnKey "{ENTER}", Me.CodeName & ".GoBack"
            .OnKey "{Down}", Me.CodeName & ".GoBack"
            .OnKey "~", Me.CodeName & ".GoBack"
        Else
            .OnKey "{TAB}"
            .OnKey "{ENTER}"
            .OnKey "{Down}"
            .OnKey "~"
        End If
    End With

   
End Sub
Private Sub GoBack()
LastR = Sheets("Weekly Data Input").Cells(Rows.Count, "F").End(xlUp).Row
Range("G" & LastR).Select
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,225,761
Messages
6,186,883
Members
453,381
Latest member
CGDobyns

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