Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing a "Counter" Value from a Sub

If you create a public variable, and don't (very important) define the same
name in the subs, there is only one vraiable, and wherever that is changed
it will be picked up in the other module. For instance, try this

Public Count

Sub MySub()
Count = 1
msgbox "MySub: " & Count
Fred
msgbox "MySub: " & Count
End Sub

Sub Fred()
Count=Count+1
msgbox "Fred: " & Count
End Sub

You should see
MySub: 1
Fred: 2
MySub: 2
--

HTH

RP
(remove nothere from the email address if mailing direct)


"JimFor" wrote in message
...
Thanks. I'll try these. If I make a variable a Public variable and it

appears
in Fred, would MySub automatically use the value I assign it in Fred no

matter
what it would have been in MySub without what happens in Fred? Not sure

this
is happening with. me.



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
How do I stop "global" hyperlinks changing to "local" links? Em Excel Worksheet Functions 2 August 26th 08 01:18 PM
How do I set up a "roll over" counter in excel 2003? mcorson Excel Worksheet Functions 1 March 6th 07 09:10 PM
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM
Excel: Changing "numeric $" to "text $" in a different cell. Heather_CCF Excel Worksheet Functions 1 September 5th 06 06:06 PM
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM


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