I would like a macro to run every time I press the enter key anywhere on a specific sheet. I will be entering data in several cell before pressing enter, so the macro only needs to run once enter is press and not when the cells are changed.
I would like a macro to run every time I press the enter key anywhere on a specific sheet. I will be entering data in several cell before pressing enter, so the macro only needs to run once enter is press and not when the cells are changed.
This goes in the worksheet module, right click the sheet tab and select View Code
One is the worksheet change, and the other is the selection change
Use the one you want.
Ussually one would onlt want the code to run when a specific range is selected, but you have not determined that.
Look at my other examples here.![]()
Please Login or Register to view this content.
http://www.davesexcel.com/vbacodes.htm#858300135
Try:
![]()
Please Login or Register to view this content.
let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source
If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE
Walking the tightrope between genius and eejit...
Deleted reply
Hi Olly,
I've manage to get yours to work, but how do I call the macro from this point. I removed the "MsgBox "Enter pressed to commit changes"" and replaced it with Call Macro (the macro is called macro) and an error run time appears.
Thanks,
If I emphasize the (ONLY) word.. and ignore your #ofPost.. and assume you as a intermediate level of Excel user.. then
I would like to suggest.. this one..
On this_Workbook..
In a separate Module..![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
BTW.. dont forget to change all the {CAPSLOCK} to {ENTER}
EDIT: Please Ignore.. as I think.. you really need (only) Worksheet_change events..![]()
Last edited by Debraj Roy; 12-17-2014 at 12:49 PM.
Regards!
=DEC2HEX(3563)
If you like someone's answer, click the star to give them a reputation point for that answer...
Should work. This does:
If that's still not working, try attaching your workbook so I can see what's going on.![]()
Please Login or Register to view this content.
Hi Dave,
I've put the code in and it runs every time I select a cell, I only need it to run when I press the "Enter" key. Am I missing something?
Thanks,
Hi Olly,
Okay it wasn't working a minute ago, but now it seems to be all good.
Thanks heaps for your help. If it comes up with an error again I'll send you a sample.
Thanks again.
My idea was that everytime you press enter you would be selecting another cell anyway. So why not use the selection_change event.
Is there a specific range you would want the code to activate?
Check post # 6..
Another approach.. to limit it within a sheet..
![]()
Please Login or Register to view this content.
and final one.. with API..
On a Module ..
and in sheet_SelectionChange event..![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks