ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   address in VBA (https://www.excelbanter.com/excel-discussion-misc-queries/162681-address-vba.html)

peyman

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

Dave Peterson

address in VBA
 
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.

peyman wrote:

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


--

Dave Peterson

JE McGimpsey

address in VBA
 
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"



In article ,
peyman wrote:

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


peyman

address in VBA
 
tahnx Dave.

"Dave Peterson" wrote:

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.

peyman wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com