vba - Excel cells share the same memory address -
i checking memory addresses excel cells using undocumented function objptr. surprised find different cells can share same address in memory. doesn't create sense... can explain weird thing?
sub testobjptr() dim objtest range set objtest = range("a1") dim integer = 1 10 debug.print join(split(objtest.address, "$"), "") & " @ " & objptr(objtest) set objtest = objtest.offset(i, i) next end sub
here output in immediate window:
a1 @ 80276608
b2 @ 80276928
d4 @ 80276608
g7 @ 80276928
k11 @ 80276608
p16 @ 80276928
v22 @ 80276608
ac29 @ 80276928
ak37 @ 80276608
at46 @ 80276928
i surprised find different cells can share same address in memory.
no. different cells not sharing same address in memory. object objtest
is. a pointer created each time variable assigned.
try this. here see objects reference same cell allocated different address in memory.
sub testobjptr() dim rng1 range, rng2 range, rng3 range, rng4 range set rng1 = range("a1") set rng2 = range("a1") set rng3 = range("a1") set rng4 = range("a1") debug.print join(split(rng1.address, "$"), "") & " @ " & objptr(rng1) debug.print join(split(rng2.address, "$"), "") & " @ " & objptr(rng2) debug.print join(split(rng3.address, "$"), "") & " @ " & objptr(rng3) debug.print join(split(rng4.address, "$"), "") & " @ " & objptr(rng4) end sub
output
a1 @ 202834688 a1 @ 260111360 a1 @ 260111744 a1 @ 260091264
excel vba excel-vba
No comments:
Post a Comment