View Single Post
  #3   Report Post  
Peter Rooney
 
Posts: n/a
Default

David,

Thanks for taking the time to answer this question.

At least you didn't laugh...

Pete

"David Hepner" wrote:

Peter,

You are correct that you can have a range "Data" in several worksheets and
since that is possible in order to access those ranges in VBA you will have
to specify which worksheet the range "Data" you are trying to reference.

For example:

Sheets("Sheet1").Application.Goto Reference:="Data"

I hope this answers your question.



"Peter Rooney" wrote:

As a hardened Excel/VBA nut, I'm probably going to be really embarrased when
I get the answer to this, but here goes...

I have a workbook containing a worksheet that records weekly data. I have a
named range ("Data") which I select then clear, via GoTo.
Each week, I copy the latest week's worksheet and create a new worksheet for
the new week. And each week, I select the range "Data" and clear it in the
most recently created worksheet.

the thing is, I always thought that Range names were unique across a
workbook, and that you couldn't have the same Range Name in more than one
worksheet.
Yet each week, I create a new worksheet, GoTo "Data" (which always selects
the correct range in the active worksheet) to create a new template for the
new week.

Excelers, MVPs and the whole of the Western hemisphere will probably be
slapping their heads in disbelief at the dumbness of this question (I have
green ticks for helping people on here, would you believe..?) If I wanted to
refer to "Data" in VBA, I suppose I'd have to qualify it with a worksheet
name.

Can anyone put me straight as to what the rules are?

Thanks (in a terminally bewildered "What's my name again?" sort of way)

Pete