Simple One: Auto-Select Adjacent Cell

Frith

Board Regular
Joined
Nov 1, 2009
Messages
99
Morning...

Trust me, there's a method to the below madness...

In range A1:A10, I'm just trying to auto-select the next lower cell. For instance, when I click on A1, I need the curser to automatically jump to A2. There's just one thing - I need the curser to jump "into" that lower cell (i.e., so that it's "blinking" in the cell, as if I had double-clicked it).

Much thanx,
Frith
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Maybe:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Application.EnableEvents = False
 
On Error GoTo ExitHere
 
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
    Target.Offset(1, 0).Select
    SendKeys "{F2}"
End If
 
ExitHere:
Application.EnableEvents = True
 
End Sub
 
Upvote 0
Thanks a lot! BTW, is there any way to do this while having the option to successfully select the cell on the "second" attempt? That is, I select A1, the cursor gets bumped down to A2 (per code). But if I select A1 a "second" time, the cursor remains on A1 (per normal routine)?

Thanx again,
Frith
 
Upvote 0
Try this:
Code:
Dim PrevSel As Range
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Application.EnableEvents = False
 
On Error GoTo ExitHere
 
If PrevSel Is Nothing Then Set PrevSel = Range("A1")
 
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
    If Target.Address <> PrevSel.Address Then
        Set PrevSel = Target
        Target.Offset(1, 0).Select
        SendKeys "{F2}"
    Else
        SendKeys "{F2}"
    End If
End If
 
ExitHere:
Application.EnableEvents = True
 
End Sub
 
Upvote 0
On second thoughts, this might work better.
Code:
Dim PrevSel As Range
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Application.EnableEvents = False
 
On Error GoTo ExitHere
 
If PrevSel Is Nothing Then Set PrevSel = Range("B1")
  
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
    If Target.Address <> PrevSel.Address Then
        Set PrevSel = Target
        Target.Offset(1, 0).Select
        SendKeys "{F2}"
    Else
        SendKeys "{F2}"
    End If
Else
    Set PrevSel = Target
End If
 
ExitHere:
Application.EnableEvents = True
 
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,993
Members
449,480
Latest member
yesitisasport

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