Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Reference to a different Sub

pontiy, You can't reference another sub, but you can keep the data from
that sub by declaring a Public variable. See example below. This way the
data is availble for any sub you wish to use it in.

enjoy, Rick

PS: Declare the public variable at top of UserForm Code, or in Code
Module...


Option Explicit
Public Ans as Variant

Private Sub CommandButton1_Click()

Ans = InPutBox(prompt:="What is your answer?")
.....
End Sub

Private Sub CommandButton5_Click()
Range("A1").value = Ans

End sub


"pontiy" wrote in
message ...

I'd appreciate you answering this question for me.


I have prompted the user for an input in one of my subs:
Private Sub CommandButton1_Click()

And now I need to use this data in a different sub:
Private Sub CommandButton5_Click()

How do I reference to a different sub to get my value?

Thank you.


--
pontiy
------------------------------------------------------------------------
pontiy's Profile:

http://www.excelforum.com/member.php...o&userid=32885
View this thread: http://www.excelforum.com/showthread...hreadid=528325



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
Changing sheet reference to cell reference TeeJay Excel Worksheet Functions 3 October 19th 07 11:50 AM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
Formulas that reference cells that reference another cell Andrea Excel Discussion (Misc queries) 7 October 19th 06 08:14 AM
Row reference increment but preserve column reference Pwanda Excel Worksheet Functions 1 April 28th 05 01:12 PM
Macro to Reference Column Next to Current Reference dolphinv4 Excel Discussion (Misc queries) 2 April 11th 05 08:36 AM


All times are GMT +1. The time now is 10:43 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"