Thread: Naming a Range
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Naming a Range

Is it RI or R1. R1 is not a legal name because it is too close to a cell
reference. I didn't have any problem naming a range RI.

--
Regards,
Tom Ogilvy

"jacqui" wrote in message
...
Bob
My code is as follows, VBA doesn't seem to like the line
where I'm using Selection.CurrentRegion.Name etc. FYI
either the title in cell A1 or the worksheet name could be
used to name the range as these are both the same. For
example the worksheet is called RI and the text appearing
in cell A1 is RI.
Hope this makes sense.
Thanks
Jacqui

Private Sub Name_Range(ws As Worksheet)

With ws
.Range("a3").Select
Selection.EntireRow.Delete
ws.Range("a1").Select
Selection.CurrentRegion.Name = Range("A1").Value
'I also tried the following line as well
'Selection.CurrentRegion.Name = ws.Name
End With

End Sub



-----Original Message-----
Jacqui,

I'm confused. Where is the sheet name gotten from, and

which range and
where?

You can add a sheet and name it with

Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = myVar

You can add a name with

myRange.Name = myRangeName

Show us the code so we can apply it.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"jacqui" wrote in message
...
Can anyone kindly help with the following?

My source data is held on a worksheet called "data".

The
range is named (using CurrentRegion) "DatArea". My

macro
makes copies of the data worksheet so that I can
manipulate the copied sheets in various ways thus

leaving
the original sheet intact. I use various Private Subs

to
delete columns and resort columns. Each copied

worksheet
is named using a title from a table, such as RI, UKGAAP,
FGAAP. The number of copies is controlled by a Do Until
Loop so the macro knows when to stop.
My question is ...when VBA copies the sheet, I'd like to
name the range according to the name of the worksheet.

The
range name will therefore vary on each loop. I really
should be able to get my head around this but for some
reason I'm having a complete mental block today, can
anyone help me out, urgently.

Thanks very much
Jacqui




.