Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default send sub routine variable to global

so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default send sub routine variable to global

Hi
Declare the variable outside the sub at the top of the module, but
define it as you did inside the sub.
Then
Dim myVariable
at the top of the sub can be used inside that module.
Also
Public myVariable
at the top of the sub can be used inside the project

regards
Paul

Nigel wrote:

so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default send sub routine variable to global

Make it a function and return that value as the function result to the
caller.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Nigel" wrote in message
ups.com...
so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?



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
Global variable dhstein Excel Discussion (Misc queries) 2 October 30th 09 01:03 PM
Error #1004 routine send emails Gus[_2_] Excel Discussion (Misc queries) 0 June 7th 07 01:23 AM
How to keep a Variable alive after a Call to Sub Routine Dennis Excel Discussion (Misc queries) 2 July 27th 05 10:57 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
VBA routine to assign first name only to a variable fitful_thought Excel Programming 6 August 3rd 04 01:39 PM


All times are GMT +1. The time now is 01:56 PM.

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"