Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default global variables

Hello, i have been searching the threads to get some info, but nothing
answered 100% my question. Is there another way to have access to the
variable size than using the call in the following code:


Option Explicit
Public size As Integer

Public Sub test1()
size = Cells(1, 1)
End Sub

Public Sub test2()
Call test1
Cells(2, 1) = size * 2
End Sub

thanks, Nicolas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default global variables

Remove the size variable and use a function that returns the value previously
stored in size:

Public Function test1() as Long
Test1 = Worksheets("Shee1").Cells(1, 1).Value
End Function

Public Sub test2()
Cells(2, 1) = Test1 * 2
End Sub

--
Regards,
Tom Ogilvy



"Nicolas Roth" wrote:

Hello, i have been searching the threads to get some info, but nothing
answered 100% my question. Is there another way to have access to the
variable size than using the call in the following code:


Option Explicit
Public size As Integer

Public Sub test1()
size = Cells(1, 1)
End Sub

Public Sub test2()
Call test1
Cells(2, 1) = size * 2
End Sub

thanks, Nicolas


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default global variables

You could do something like this:

Function Get_Size()
Get_Size = Cells(1,1)
End Function

Sub Test2()
Cells(2,1) = Get_Size() * 2
End Sub

Though I'm not sure exactly what you're looking for so not sure if
that's going to be any help.


Nicolas Roth wrote:
Hello, i have been searching the threads to get some info, but nothing
answered 100% my question. Is there another way to have access to the
variable size than using the call in the following code:


Option Explicit
Public size As Integer

Public Sub test1()
size = Cells(1, 1)
End Sub

Public Sub test2()
Call test1
Cells(2, 1) = size * 2
End Sub

thanks, Nicolas


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default global variables

thanks for your answer, but actually what i would like to dois to
define all the variables i will use in the others modules. so there
will be more than one, and there will also be worksheets and workbooks.
John Fuller wrote:
You could do something like this:

Function Get_Size()
Get_Size = Cells(1,1)
End Function

Sub Test2()
Cells(2,1) = Get_Size() * 2
End Sub

Though I'm not sure exactly what you're looking for so not sure if
that's going to be any help.


Nicolas Roth wrote:
Hello, i have been searching the threads to get some info, but nothing
answered 100% my question. Is there another way to have access to the
variable size than using the call in the following code:


Option Explicit
Public size As Integer

Public Sub test1()
size = Cells(1, 1)
End Sub

Public Sub test2()
Call test1
Cells(2, 1) = size * 2
End Sub

thanks, Nicolas


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 Variables [email protected] Excel Programming 0 July 7th 06 10:53 AM
global variables Mike Archer Excel Programming 4 May 3rd 06 07:33 PM
Global Variables mattsvai[_11_] Excel Programming 4 February 3rd 06 05:02 PM
Global Variables Francis Brown Excel Programming 9 November 27th 05 06:14 PM
global variables [email protected] Excel Programming 3 November 16th 05 11:44 PM


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