View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default 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