View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default Add name by vba based on cell content

I'm assuming that if the current cell is D7 and contains the word "bob" then
you want to name the range E8:H12 "bob"

Sub test()
Dim r As Range, s As String
With ActiveSheet
Set r = ActiveCell
s = r.Text
Set r = .Range(r.Offset(1, 1), r.Offset(5, 4))
ThisWorkbook.Names.Add Name:=s, RefersTo:=r
End With
End Sub

--
XL2002
Regards

William



"christobal " wrote in message
...
| Have need of a vba snippet which will pass the contents of the
| activecell as the "name" of a named range with reference to the
| 4 columns to the right and 5 rows below the activecell as the range
| area
| Any ideas !
|
|
| ---
| Message posted from
http://www.ExcelForum.com/
|