Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create Named Range for each unique value

Hi!

All help is welcome here... Am really stuck.

What I have is a list of room numbers. Many appear multiple times i
column A, but it will always be sorted.

What I need is a way to easily create Named Ranges for each group of
rooms. (ie all rows with value 1 becomes one named range, rows with
value 5 becomes one named range and so on)

Range Name should prefereable be same a room name.

Would like the code to go through column A and create ranges for each
unique value. (could also have a "supporting" sheet with uniqe values
if necessary)

Any takers?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Create Named Range for each unique value

If the values are sorted:

Sub RangeMaker()
Set r = Cells(1, 1)
n = Cells(Rows.Count, 1).End(xlUp).Row + 1
For i = 2 To n
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Set r = Union(r, Cells(i, 1))
Else
r.Name = "Name" & Cells(i - 1, 1).Value
Set r = Cells(i, 1)
End If
Next
End Sub

--
Gary''s Student - gsnu200909


"littleme" wrote:

Hi!

All help is welcome here... Am really stuck.

What I have is a list of room numbers. Many appear multiple times i
column A, but it will always be sorted.

What I need is a way to easily create Named Ranges for each group of
rooms. (ie all rows with value 1 becomes one named range, rows with
value 5 becomes one named range and so on)

Range Name should prefereable be same a room name.

Would like the code to go through column A and create ranges for each
unique value. (could also have a "supporting" sheet with uniqe values
if necessary)

Any takers?
.

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
Create Named Range in VBA michael.a7[_5_] Excel Programming 2 June 9th 06 12:00 AM
Create named range Matee Excel Programming 1 April 4th 06 03:40 AM
Extracting unique entries and assigning it to a named range Hari Excel Discussion (Misc queries) 0 December 13th 05 06:29 AM
Extracting unique entries and assigning it to a named range Hari Excel Programming 3 December 12th 05 09:58 AM
Create named range Robert[_16_] Excel Programming 2 October 27th 03 11:57 PM


All times are GMT +1. The time now is 10:08 PM.

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"