Auto-Select Cell After 10 Seconds

Frith

Board Regular
Joined
Nov 1, 2009
Messages
99
Hello there,

I would like to know how I could have Excel auto-select -- i.e., move the cursor to -- the last non-blank (>0) cell in column A, ten seconds after the last cell input/edit was made anywhere within the same WS? Is this possible, via any VBA code?

Thank you,
Frith
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Frith,

The below code will do what you want but the drawback is that it won't allow editing for the ten seconds. If there is a way to do it and allowing editing that would be nice to know; however, I am not sure it can be done.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim LastColACell As Range
    Set LastColACell = Cells(Rows.Count, 1).End(xlUp)
    '// If the cell just changed is the same as the last non-Blank no wait.
    If Not Intersect(Target, LastColACell) Is Nothing Then Exit Sub
    Application.Wait Time + TimeSerial(0, 0, 10)
    LastColACell.Select
End Sub
 
Upvote 0
Hey Ralajer, thanks & sorry for the delayed response... Actually, while that code "does" what it should, the "way" in which it does (i.e., precluding any edits, as you note) is what's precluding me from using it. Any one here have any ideas?

Thanx again,
Frith
 
Upvote 0
Here's one way. All the code goes in the sheet's module.
Code:
Private RunWhen As Double

Private Sub Worksheet_Change(ByVal Target As Range)
       
    'Restart timer
    
    StopTimer
    StartTimer
    
End Sub

Private Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, 10)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=Me.CodeName & ".SelectCell", Schedule:=True
End Sub

Private Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:=Me.CodeName & ".SelectCell", Schedule:=False
End Sub

Private Sub SelectCell()

    'Select last non-blank cell in column A
    
    Cells(Rows.Count, "A").End(xlUp).Select
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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