Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default 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...
  #4   Report Post  
Posted to microsoft.public.excel.programming
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
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
referencing a variable from a form in a module Matthew Dyer Excel Programming 2 October 7th 09 10:57 PM
VBA code in one Module referencing Public Variables Declared inanother Module failing Khurram Excel Programming 5 March 11th 09 11:01 PM
Transfer Variable from Form to Module Gleam Excel Programming 2 September 6th 07 05:54 AM
Access variable from form and module? parkin_m Excel Programming 1 August 8th 07 03:32 PM
Unload A Form based on a Variable in my Module [email protected] Excel Programming 4 May 2nd 07 11:11 PM


All times are GMT +1. The time now is 05:30 PM.

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"