Function to populate a cell with a mouse click.
- ShaunWhite
- Posts: 10509
- Joined: Sat Sep 03, 2016 3:42 am
You can record macros and assign them to a buttons.
When you look at the VBA code that was generated as you typed, you will take a giant leap forward into understanding the world of programming. You'll soon see that anything and everything about your spreadsheet is under your control and available at the click of a button, literally.
When you look at the VBA code that was generated as you typed, you will take a giant leap forward into understanding the world of programming. You'll soon see that anything and everything about your spreadsheet is under your control and available at the click of a button, literally.
+1ShaunWhite wrote:You can record macros and assign them to a buttons.
Excel VBA is incredibly powerful. However, every now and then you'll come across something that should be simple, but isn't. And left/right mouse buttons is one of those things.98lewisj wrote:Is it possible to populate a cell in excel with a left or right click of a mouse.
Basically, Excel traps the Right button quite easily. But to monitor the left button, you have to delve into a Windows API (the underlying Windows 'code').
So it's possible, but not neat. You can google it (and read all the frustration people have). I'm attaching an example spreadsheet that shows the code in action. You'll need to 'Enable Macros' when you open it.
Left or Right click on cell A1 and the code will update that cell contents with the date/time and which button you used.
One limitation - it always moves the selected cell to A2 after updating A1. There is a reason for that...
Hope that helps
Ian
Credits - These two solutions were combined in the attached file:
http://vba-corner.livejournal.com/639.html
https://www.experts-exchange.com/questi ... -cell.html
You do not have the required permissions to view the files attached to this post.