Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Defining Variables that pass to other Subs

I have two Subs, in the first I define a variable and in the second I
recall this variable. here is how I am trying to do it (its not
working)


Private Sub TaskBox_Change()
Dim Task As String
Task = TaskBox.Value
End Sub

Public Sub Next()
ActiveCell.FormulaR1C1 = Task
End Sub

This is just a basic representation that I am trying to show of what is
not working. I can not figure out how I am to get the Variable defined
in the Sub "TaskBox_Change" passed to the Sub "Next"

Any help or guidance would be greatly appreciated.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Defining Variables that pass to other Subs

Here's how:

Define the variable on a module level. You code would read:

Dim Task As String

Private Sub TaskBox_Change()
Task = TaskBox.Value
End Sub

Public Sub Next()
ActiveCell.FormulaR1C1 = Task
End Sub

Any variable defined inside of a Sub is only available in that sub.



--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Defining Variables that pass to other Subs

thank you

--
Message posted from http://www.ExcelForum.com

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
Defining a Range using Variables Billyruben Excel Discussion (Misc queries) 3 December 2nd 08 06:31 PM
Defining Variables with Same Name in Different Worksheets mhyzak Excel Discussion (Misc queries) 1 May 3rd 07 10:25 PM
VBA defining variables Jeff Excel Discussion (Misc queries) 2 November 3rd 05 11:33 PM
solver and defining all variables different than one another excel_excel_excel Excel Discussion (Misc queries) 0 July 19th 05 07:38 AM


All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"