Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation Procedure with a worksheet change event Bhupinder Rayat Excel Worksheet Functions 2 October 3rd 07 05:18 PM
workbook_Open event Procedure peerless Excel Discussion (Misc queries) 1 May 22nd 06 10:21 PM
workbook_Open event Procedure peerless Excel Discussion (Misc queries) 0 May 22nd 06 10:16 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM
ComboBox Event Procedure problem Brent McIntyre Excel Programming 1 September 18th 03 02:01 PM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"