Function to populate a cell with a mouse click.

Discussion regarding the spreadsheet functionality of Bet Angel.
Post Reply
98lewisj
Posts: 116
Joined: Fri Nov 08, 2013 4:17 am

Is it possible to poplate a cell in excel with a left or right click of a mouse. For example, If I was to right click a 1 would populate in a certain cell and If I was to left click a 2 would populate? Any suggestions/Ideas? Cheers.
User avatar
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.
User avatar
EyePeaSea
Posts: 258
Joined: Sun Jun 12, 2011 11:18 am

ShaunWhite wrote:You can record macros and assign them to a buttons.
+1
98lewisj wrote:Is it possible to populate a cell in excel with a left or right click of a mouse.
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.

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.
98lewisj
Posts: 116
Joined: Fri Nov 08, 2013 4:17 am

Thanks guys, I have solved the issue now. I would have never have done it on my own but a fellow trader managed to fix it for me.
Post Reply

Return to “Bet Angel - Spreadsheet / Excel chat”