Excel VBA Global Range variable out of scope after sub procedure completes -


i perplexed why global variable within module fall out of scope @ conclusion of sub procedure.

i declare range @ top of module out side of subproc , functions below

option explicit  dim timedata range dim freqdata range  const startloc = "b4" const flowloc = "f4" const dtloc = "j8" 

in subproc define 1 of ranges.

public sub portandconvertdata()  <snip>  set timedata = calcsheet.range(cells(2, 2).address, cells(2 + datasize, 2).address)  end sub 

after sub completes in watch window see variable timedata go range/range range , value go correct out of context.

i want store data in module rather pasting in sheet or something.

any appreciated

make sure context in watch properties includes procedure/module watching. can make sure setting context modules:

from watches panel: right click expression --> edit watch --> context group set procedure/module all.

if not actual issue, having same issue i'm having access vba.

this thread explains same: thisworkbook not holding global variable value cancel ontime()


Comments