Push a button or push a key

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
1,012
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Hi All,

Is it possible entering information from a user into a worksheet either pushing button on the form control or key input (user form is active). For example if user needs to enter employee cod (let say 8) he can push button “8” on user form or push key 8. If yes what is the macro cod?
Thank you in advance
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
thank you for reply

If I click with mouse pointer on userform’s button CommandButton8 it should enter 8 on cell A1
If on keyboard I push the key 8 it should enter 8 on cell A1.
Either of them should work
 
Upvote 0
ok then yes, use the form keydown event and would go something like

if keycode = 56 or keycode = 104 then
thisworkbook.sheets("Sheet1").range("a1").value = "8"
else
end if

the keycode 56 is the normal number 8 key and 104 is the num pad.

to find the codes enter under keydown event
msgbox (keycode)
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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