LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default many similar event procedures

I have written a macro, which contains many userform. each userform
contains many comboboxes (in addition to may other controls) I want
several things to happen when the value in the combobox is changed.
Here is an example of the code that i currently have in the combobox
change event procedu

Private Sub ComboBox10_Change()
Dim ftype As Integer
Recalc
ftype = 2 + ComboBox10.ListIndex
Call PriceToCell(12, ComboBox10, 20, ftype)
End Sub

Private Sub ComboBox11_Change()
Dim ftype As Integer
Recalc
ftype = 2 + ComboBox11.ListIndex
Call PriceToCell(12, ComboBox11, 18, ftype)
End Sub

etc....

I repeat this code many times where everything is almost exactly the
same, except for the text "ComboBox10" would be the name of the
combobox, and the the text "20" is specific for each combobox.

what i would like to do is make this code generic so that i can copy it
everywhere i need it without having to change it everytime, or even
better refer to a procedure in my main module call..... so my first
idea is initializing the combobox so that the value of combobox.tag in
this case would be 20. Then i could replace the text 20, which is
specific with something like Cint(ComboBox10.tag). But i still need to
find some way to replace the specific ComboBox name, not in the name of
the procedure, but only within the procedure. I have some idea that
there is a solution to this involving setting up a class module, but i
am not sure that i understand all the complexity of that. I thought
the generic "Me" might work, but that gives me an error.

any advice you have would be a big help.

 
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
Event Procedures in an Add-In DJB[_10_] Excel Programming 3 September 17th 05 08:11 AM
learning event procedures R.VENKATARAMAN Excel Programming 4 January 21st 05 01:09 PM
Event procedures (and the temple of doom) Mark Tangard[_3_] Excel Programming 2 July 20th 04 04:45 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
Creating Event procedures from a macro Robert Stober Excel Programming 3 September 7th 03 06:52 PM


All times are GMT +1. The time now is 12:39 PM.

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

About Us

"It's about Microsoft Excel"