Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Same event procedure for multiple controls
I have a userform with 18 TextBoxes. Their values are read from a worksheet.
On KeyPress event I write data back to worksheet. Is it possible to write a procedure which accepts textbox control as parameter as runs the same On_KeyPress sub for all 18 TextBoxes? Or may be when KeyPress event is occurred on a form, is it possible to determine which TextBox is active and do necessary actions on this TextBox? Thanks in advance, Mike510 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Same event procedure for multiple controls
You can use the technique documented by John Walkenbach:
http://j-walk.com/ss/excel/tips/tip44.htm Handle Multiple UserForm Buttons With One Subroutine This uses commandbuttons, but can be adapted for textboxes. Note that only the events specific to the control can be handled this way. Events, such as the exit event, inherited from the control object, can not be handled this way. It sounds like your textboxes are linked to cells, however. The link is a two way street - if you make an entry in the textbox, it is also placed in the linked cell. - make sure you are not fighting yourself, so to speak. -- Regards, Tom Ogilvy "Mikhail" wrote in message ... I have a userform with 18 TextBoxes. Their values are read from a worksheet. On KeyPress event I write data back to worksheet. Is it possible to write a procedure which accepts textbox control as parameter as runs the same On_KeyPress sub for all 18 TextBoxes? Or may be when KeyPress event is occurred on a form, is it possible to determine which TextBox is active and do necessary actions on this TextBox? Thanks in advance, Mike510 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Validation Procedure with a worksheet change event | Excel Worksheet Functions | |||
workbook_Open event Procedure | Excel Discussion (Misc queries) | |||
workbook_Open event Procedure | Excel Discussion (Misc queries) | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming | |||
ComboBox Event Procedure problem | Excel Programming |