Thread: ReferesTo
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default ReferesTo

It's a coincidence.

You already have a defined name (maybe manually, maybe a dynamic name???) that
coincides with the range in column A.

So NameRange.Name returns something like:
=Sheet1!$A$1:$A$12

But you don't have an existing name that coincides with the range described in
your code.

So you got lucky by getting the column A version to work (since it did what you
wanted).

Or you got lucky by getting the column B version to fail (so you don't rely on
this).

Joel wrote:

Can somebody explain why ReferesTo works in column A and Not in Column B

LastRowA = .Range("A" & Rows.Count).End(xlUp).Row
Set NameRange = .Range("A1:A" & LastRowA)
NameStr = Mid(NameRange.Name.RefersTo, 2)
Set DateRange = .Range("B1:B" & LastRowA)
DateStr = Mid(DateRange.Name.RefersTo, 2)


--

Dave Peterson