Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Variable with value before being assigned?

Did you declare it at the top of the module outside any sub/function.

These variables hold there value between code executions. You can see what
happens in a test module:


Option Explicit
Dim iCtr As Long

Sub testme01()
iCtr = iCtr + 1
MsgBox iCtr
End Sub
Sub testme02()
Dim jCtr As Long
jCtr = jCtr + 1
MsgBox jCtr
End Sub


Did you declare the variable as Public in a different module? That makes it
visible to all the modules and it'll also retain the current value between
executions.

Did you declare the variable as static?
Sub testme03()
Static lCtr As Long
lCtr = lCtr + 1
MsgBox lCtr
End Sub

I'm guessing that it's a public variable in a different module.

Hit Ctrl-F (Edit|Find) within the VBE and search for that variable name. But
make sure you check the "current Project" option button.

Then hit Find Next (or F3 when you dismiss that Find dialog).


Jon wrote:

When I execute a piece of code (pressing f8 once), and I hover the
cursor over a variable, I find that there is value already assigned.
I can't find this in the declaration section or anywhere else where
this value gets assigned. Does anyone know how this can happen?


--

Dave Peterson

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
assigned cell names Texas Tonie[_2_] Excel Discussion (Misc queries) 1 July 25th 07 11:59 PM
Save assigned button Deedles Excel Discussion (Misc queries) 2 September 6th 06 09:46 PM
How do I know what macro is assigned to a button? Denise in NC Excel Discussion (Misc queries) 3 April 3rd 06 02:31 PM
fourmla with result no less than assigned value Jane Excel Worksheet Functions 1 January 13th 05 07:16 AM


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