![]() |
referencing a variable from a form in a module
I have a form with 4 different text boxes in a form. When a command
button is pressed on the form, the values are saved into variables that I want to use in a module sub saved in the same excel workbook, but i seem to be striking out... How do i accomplish this? |
referencing a variable from a form in a module
In a General module (not in the userform module, not in a worksheet module, not
in the ThisWorkbook module), declare your 4 variables and make them public. Option Explicit Public myVar1 as string etc Then when your userform is ready (in the okbutton click event???): myVar1 = me.textbox1.value etc Matthew Dyer wrote: I have a form with 4 different text boxes in a form. When a command button is pressed on the form, the values are saved into variables that I want to use in a module sub saved in the same excel workbook, but i seem to be striking out... How do i accomplish this? -- Dave Peterson |
referencing a variable from a form in a module
On Oct 7, 1:28*pm, Dave Peterson wrote:
In a General module (not in the userform module, not in a worksheet module, not in the ThisWorkbook module), declare your 4 variables and make them public. Option Explicit Public myVar1 as string etc Then when your userform is ready (in the okbutton click event???): myVar1 = me.textbox1.value etc Matthew Dyer wrote: I have a form with 4 different text boxes in a form. When a command button is pressed on the form, the values are saved into variables that I want to use in a module sub saved in the same excel workbook, but i seem to be striking out... How do i accomplish this? -- Dave Peterson What do you mean by General Module? I can only create Modules in a workbook... |
referencing a variable from a form in a module
Open excel
Go into the VBE. Click on Insert and choose module You may not be able to create a module for each worksheet, but excel can. You may not be able to create a module for ThisWorkbook, but excel can. You can create a userform and excel will create the module that sits behind that userform. You can insert a class module, too. Matthew Dyer wrote: On Oct 7, 1:28 pm, Dave Peterson wrote: In a General module (not in the userform module, not in a worksheet module, not in the ThisWorkbook module), declare your 4 variables and make them public. Option Explicit Public myVar1 as string etc Then when your userform is ready (in the okbutton click event???): myVar1 = me.textbox1.value etc Matthew Dyer wrote: I have a form with 4 different text boxes in a form. When a command button is pressed on the form, the values are saved into variables that I want to use in a module sub saved in the same excel workbook, but i seem to be striking out... How do i accomplish this? -- Dave Peterson What do you mean by General Module? I can only create Modules in a workbook... -- Dave Peterson |
All times are GMT +1. The time now is 05:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com