How do I make a sub run when a specific cell is selected, as opposed to running any time a cell is changed? Is it possible also to make a subroutine run when I press "Enter"?
Thank you
How do I make a sub run when a specific cell is selected, as opposed to running any time a cell is changed? Is it possible also to make a subroutine run when I press "Enter"?
Thank you
Use the Selection Change event handler as opposed to the Change event handler.
I suspect pressing Enter would be considered a change ... but maybe not. Have you tried it?
Regards, TMS
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
^ That is what I would normally do. What I mean is, what if I want the sub to run when I select, say, cell A3?
Check the Address of Target.
If posting code please use code tags, see here.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address="$A$3" Then
.
.
.
End If:End Sub
If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)
You can't do one thing. XLAdept
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin
Thank you!
You're welcome!![]()
You're welcome. Thanks for the rep.
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
New quick method:
Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.
Or you can use this way:
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks