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

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

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