Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables From TextBoxes
I am trying to capture a variant using a TextBox for use later on in seperate Macro. The first part of the macro works fine and captures th data I require but it seems to lose the variable later on. I use a Form with 3 TextBoxes to capture 3 dates - date1, date2, date3 Upon clicking the OK button (CommandButton1) the contents of th textboxes are "transfered" to variables date1, date2, date3 - as see below. Public Sub CommandButton1_Click() Dim date1, date2, date3 As Variant date1 = TextBox1 date2 = TextBox2 date3 = TextBox3 Unload UserForm1 End Sub Then I wish to run the following code to return these dates vi keypresses no data is returned. Sub Fkeyson() Application.OnKey "{F10}", "doDate1" Application.OnKey "{F11}", "doDate2" Application.OnKey "{F12}", "doDate3" End Sub Sub Fkeysoff() Application.OnKey "{F10}" Application.OnKey "{F11}" Application.OnKey "{F12}" End Sub Sub doDate1() MsgBox (date1) ActiveCell.Value = date1 End Sub What do I need to do to carry the variables over from one macro t another ? Thanks in advance -- SeanEvan ----------------------------------------------------------------------- SeanEvans's Profile: http://www.excelforum.com/member.php...fo&userid=1465 View this thread: http://www.excelforum.com/showthread.php?threadid=26385 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables From TextBoxes
in a general module (the type you would get if you did Insert=Module) at
the very top, outside any procedure put in Public Date1 as Variant, Date2 as Variant, Date3 as Variant or just Public Date1, Date2, Date3 then change you click event to this Public Sub CommandButton1_Click() date1 = TextBox1 date2 = TextBox2 date3 = TextBox3 Unload UserForm1 End Sub And don't declare the date variables anywhere else. -- Regards, Tom Ogilvy "SeanEvans" wrote in message ... I am trying to capture a variant using a TextBox for use later on in a seperate Macro. The first part of the macro works fine and captures the data I require but it seems to lose the variable later on. I use a Form with 3 TextBoxes to capture 3 dates - date1, date2, date3. Upon clicking the OK button (CommandButton1) the contents of the textboxes are "transfered" to variables date1, date2, date3 - as seen below. Public Sub CommandButton1_Click() Dim date1, date2, date3 As Variant date1 = TextBox1 date2 = TextBox2 date3 = TextBox3 Unload UserForm1 End Sub Then I wish to run the following code to return these dates via keypresses no data is returned. Sub Fkeyson() Application.OnKey "{F10}", "doDate1" Application.OnKey "{F11}", "doDate2" Application.OnKey "{F12}", "doDate3" End Sub Sub Fkeysoff() Application.OnKey "{F10}" Application.OnKey "{F11}" Application.OnKey "{F12}" End Sub Sub doDate1() MsgBox (date1) ActiveCell.Value = date1 End Sub What do I need to do to carry the variables over from one macro to another ? Thanks in advance. -- SeanEvans ------------------------------------------------------------------------ SeanEvans's Profile: http://www.excelforum.com/member.php...o&userid=14650 View this thread: http://www.excelforum.com/showthread...hreadid=263851 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Textboxes | Excel Discussion (Misc queries) | |||
tab between several textboxes | Excel Worksheet Functions | |||
Textboxes | Excel Programming | |||
textboxes | Excel Programming |