address in VBA

P

peyman

hi,
is there any difference between these two expressions:?
target.address=range("D1").address
and
target.address(false,false)=range("D1").address
thanx
 
D

Dave Peterson

Yes.

If you're using:

if target.address(false,false) = range("D1").address then
msgbox "true"
else
msgbox "False"
end if

You'll never see the True msgbox.

Try this in a test macro:

with range("D1")
msgbox .address & vblf & .address(false,false)
end with

And you'll see the difference.
 
J

JE McGimpsey

Yes. The second formula will always return False, since .address will by
default return an absolute address.

This is equivalent:

target.Address(False, False) = Range("D1").Address(False, False)


but of course, since you know the cell reference you could just as
easily use

target.Address(False, False) = "D1"
 
P

peyman

tahnx Dave.

Dave Peterson said:
Yes.

If you're using:

if target.address(false,false) = range("D1").address then
msgbox "true"
else
msgbox "False"
end if

You'll never see the True msgbox.

Try this in a test macro:

with range("D1")
msgbox .address & vblf & .address(false,false)
end with

And you'll see the difference.
 
Top