Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic nameing of ranges based on a label


I have a sheet in which I need to name a whole lot of cells. I'm getting
rsi trying to do them manually and am now trying to write some code to
name the ranges based on a label which is in the column to the right of
the cell to be named. I need to name about 50 cells going down....

I have tried my code on naming one cell first and planning to move on
to the moving down to the next cell once this is working....

However, this doesn't work!


Dim Nme As String
Dim Pos
Dim MySheet As String

Nme = ActiveCell.Offset(0, 1)
Pos = ActiveCell.Address

ActiveWorkbook.Names.Add Nme, Pos
End Sub


Please help.
Thanks in advance


--
skuzapo
------------------------------------------------------------------------
skuzapo's Profile: http://www.excelforum.com/member.php...o&userid=27430
View this thread: http://www.excelforum.com/showthread...hreadid=470655

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Automatic nameing of ranges based on a label

Assuming your list of names is in column A and you want the named cells
to be in column B then:

Sub naming()
Dim Nm As String
Dim eRow As Long
Dim i As Long
eRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To eRow
Nm = Cells(i, 1).Value
ActiveWorkbook.Names.Add Name:=Nm, RefersTo:=Cells(i, 2)
Next i
End Sub

Hope this helps
Rowan

skuzapo wrote:
I have a sheet in which I need to name a whole lot of cells. I'm getting
rsi trying to do them manually and am now trying to write some code to
name the ranges based on a label which is in the column to the right of
the cell to be named. I need to name about 50 cells going down....

I have tried my code on naming one cell first and planning to move on
to the moving down to the next cell once this is working....

However, this doesn't work!


Dim Nme As String
Dim Pos
Dim MySheet As String

Nme = ActiveCell.Offset(0, 1)
Pos = ActiveCell.Address

ActiveWorkbook.Names.Add Nme, Pos
End Sub


Please help.
Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Automatic nameing of ranges based on a label

activecell.name = activecell.offset(0,1).value

Wolf

"skuzapo" wrote:


I have a sheet in which I need to name a whole lot of cells. I'm getting
rsi trying to do them manually and am now trying to write some code to
name the ranges based on a label which is in the column to the right of
the cell to be named. I need to name about 50 cells going down....

I have tried my code on naming one cell first and planning to move on
to the moving down to the next cell once this is working....

However, this doesn't work!


Dim Nme As String
Dim Pos
Dim MySheet As String

Nme = ActiveCell.Offset(0, 1)
Pos = ActiveCell.Address

ActiveWorkbook.Names.Add Nme, Pos
End Sub


Please help.
Thanks in advance


--
skuzapo
------------------------------------------------------------------------
skuzapo's Profile: http://www.excelforum.com/member.php...o&userid=27430
View this thread: http://www.excelforum.com/showthread...hreadid=470655


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic nameing of ranges based on a label


Thanks for your help Wolf and Rowan,

Very helpful posts thank

--
skuzap
-----------------------------------------------------------------------
skuzapo's Profile: http://www.excelforum.com/member.php...fo&userid=2743
View this thread: http://www.excelforum.com/showthread.php?threadid=47065

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
nameing a worksheet Lost Excel Discussion (Misc queries) 2 April 23rd 09 08:03 AM
column nameing PAUL~H~UK Excel Discussion (Misc queries) 7 October 16th 06 11:36 PM
Automatic Sort for variable Ranges bman342 Excel Worksheet Functions 2 June 27th 06 08:51 PM
Automatic label arrangement in a pie chart Pierre Excel Discussion (Misc queries) 0 September 29th 05 04:30 PM
Programatically nameing ranges Adam Ward Excel Programming 4 May 12th 04 09:43 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"