LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default scope/ lifetime of variable

HI all,
I'm so confused about this.
I've declared a variable and assigned a value in one module and want to use
it in another (or a few) but I seem to lose the value once I leave the
standard module that I started from. I've include a code example of what I'm
trying to do.
Any help is always appreciated.

--
jeff

... I used to have a handle on life, but it broke.

'in module1
Public Sub MYPaths()
Dim vbackup As String
vbackup = Sheets("mypaths").Range("d2").Value
Debug.Print vbackup
' this works fine and I view the value perfectly in immediate window
end sub

'in module2
Public Sub Test()
debug.print vbackup
'returns nothing in the immediate window
end sub


 
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
scope/ lifetime of variable Norman Jones Excel Programming 0 September 18th 04 12:55 AM
Variable Scope Kevin Excel Programming 1 September 14th 04 07:05 PM
Variable scope TonyM Excel Programming 5 April 24th 04 01:02 PM
Scope of a public variable Jos Vens Excel Programming 0 November 24th 03 10:08 AM
module-level variable lifetime Jessie[_2_] Excel Programming 0 July 30th 03 09:31 PM


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