address in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
is there any difference between these two expressions:?
target.address=range("D1").address
and
target.address(false,false)=range("D1").address
thanx
 
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.
 
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"
 
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.
 
Back
Top