View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Naive question on Range naming but please answer

This should do it:
Sub test()
With Application.Selection
ActiveWorkbook.Names.Add Name:="Test", _
RefersTo:=Application.Selection
End With
End Sub

Mke F
"DoctorG" wrote in message
...
Is there an easy way to set the Name Property for a range when I have it
selected in code?
i.e.
Range("D_DATABASE_START").Select
Range(Selection, Selection.End(xlDown)).Select

I tried to figure this out by recording the moves involved but the
resulting
macro code states the following : ActiveWorkbook.Names.Add
Name:="test",
RefersToR1C1:="=Data!R2C1:R9C8"

I wish to avoid the R1C1 part by something that relies on the fact that
the
range is already selected in code.

Is there something like Selection.Name="test"?
Please help