Automatic offset

dkehler

New Member
Joined
Oct 15, 2009
Messages
35
I am using excel 10 and have my cursor set to move to the right and would like to do the following:

When I make an entry into any line in column A and press enter, I want the target cell to be in column E on the same line.

Then when the target cell is G, I want it to move to K.

Then when I enter and the target is M, I want to go back to A on the next line. Thanks for any help.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hopefully I read that right:

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br>    <SPAN style="color:#007F00">'   Code goes in the Worksheet specific module</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range<br>        <SPAN style="color:#007F00">'   Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> rng = Target.Parent.Range("A:A, G:G, M:M")<br>             <SPAN style="color:#007F00">'   Only look at single cell changes</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Target.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Only look at that range</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Intersect(Target, rng) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Action if Condition(s) are met (do your thing here...)</SPAN><br>            <SPAN style="color:#00007F">Select</SPAN> <SPAN style="color:#00007F">Case</SPAN> Target.Column<br>                <SPAN style="color:#00007F">Case</SPAN> 1 <SPAN style="color:#007F00">'    A</SPAN><br>                    Cells(Target.Row, "E").Select<br>                <SPAN style="color:#00007F">Case</SPAN> 7 <SPAN style="color:#007F00">'    G</SPAN><br>                    Cells(Target.Row, "K").Select<br>                <SPAN style="color:#00007F">Case</SPAN> 13 <SPAN style="color:#007F00">'   M</SPAN><br>                    Cells(Target.Row + 1, "A").Select<br>            <SPAN style="color:#00007F">End</SPAN> Select<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH,
 
Upvote 0
I see Smitty and I are two minds but with a single thought!

I have a slightly different version of the same thing.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    Select Case False
        Case Intersect(Range("A:A"), Target) Is Nothing ' If the target is A ...
            Range("E" & Target.Row).Select              ' ... go to E
        Case Intersect(Range("G:G"), Target) Is Nothing ' If the target is G ...
            Range("K" & Target.Row).Select              ' ... go to K
        Case Intersect(Range("M:M"), Target) Is Nothing ' If the target is M ...
            Range("A" & Target.Row + 1).Select          ' ... go to A on next row
    End Select
    
End Sub
 
Upvote 0
Hopefully I read that right:

Private Sub Worksheet_Change(ByVal Target As Range)
****'** Code goes in the Worksheet specific module
****Dim rng As Range
********'** Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
********Set rng = Target.Parent.Range("A:A, G:G, M:M")
************ '** Only look at single cell changes
************If Target.Count > 1 Then Exit Sub
************'** Only look at that range
************If Intersect(Target, rng) Is Nothing Then Exit Sub
************'** Action if Condition(s) are met (do your thing here...)
************Select Case Target.Column
****************Case 1 '****A
********************Cells(Target.Row, "E").Select
****************Case 7 '****G
********************Cells(Target.Row, "K").Select
****************Case 13 '** M
********************Cells(Target.Row + 1, "A").Select
************End Select
End Sub


HTH,[/QUOTE

Thanks, what parts of this do I paste into the code page on the worksheet? Dave
 
Upvote 0
RickXL. No problem with the feedback. I greatly appreciate the help. I ended up using the code from RickXL since it was a little easier to make changes to if I change the worksheet.
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

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