Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To All,
The snippet of code below (labeled "Start of Common Code") is duplicated numerous time's in a number of "Events" associated with a UserForm. All is currently working, but I'm trying now to clean up duplicate code by placing the common portions in a subroutine ... Could someone Kindly show me how to correctly reference back to the UserForm once this common code is extracted from an event and placed into a sub-routine? I thought I read an earlier post about "MSForms." ? ... or something like that, but Listbox doesn't seem to be a valid option following MSForms. ... Any assistance would be greatly appreciated. Thanks, JimP '''''''''''''snippet'''''''''' With Me.ListBoxITEM .Clear .ColumnWidths = "50" .ColumnHeads = True .RowSource = gstrRowSource .ListIndex = 0 '------ Start of Common Code ------------- ' 1st) Extract FROM: Database TO: Label's Caption LblDescription.Caption = Range(gstrRowSource).Cells(.ListIndex + 1, 2).Value LblUnitPRICE.Caption = Range(gstrRowSource).Cells(.ListIndex + 2, 3).Value ' 2nd) Copy FROM: Label's Caption TO: Custom TextBox TxtCustomDescription.Text = LblDescription.Caption TxtCustomPrice.Text = LblUnitPRICE.Caption ' 3rd) Copy FROM: Custom Price TextBox TO: Global Variable gstrDescription = TxtCustomDescription.Text gstrUnitPrice = TxtCustomPrice.Text '-------- End of Common Code ------------- End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UserForm Print Extra Copies | Excel Discussion (Misc queries) | |||
Eliminate Excel copies that have no file type | Excel Worksheet Functions | |||
eliminate data entered to a worksheet that copies to another work. | Excel Worksheet Functions | |||
Apply vba code to multiple userform objects | Excel Programming | |||
Apply vba code to multiple userform objects | Excel Programming |