Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Textboxes SAL Excel Discussion (Misc queries) 2 July 13th 07 12:24 AM
tab between several textboxes Kim Excel Worksheet Functions 0 May 9th 05 04:08 PM
Textboxes Marcotte A Excel Programming 2 July 7th 04 12:55 AM
textboxes libby Excel Programming 5 April 13th 04 06:32 PM


All times are GMT +1. The time now is 05:45 AM.

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"