Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Multiple Ranges in 1 Column using VBA

I am trying to create multiple ranges in one column using VBA.

I have a set of data in one column and I want to create ranges for each
value, eg

Data:
A
A
A
B
B
C
C
C

I would like a range for A, a range for B, a range for C etc

Thanks
Neil

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default Multiple Ranges in 1 Column using VBA

This macro does what you want. I assumed that your data is in Column A
starting in A2. Note that your data must be sorted before you run this
macro. Each range is named the value of one of the cells with "Name" after
it. In other words, if the cell value is Baker, the range name assigned is
BakerName. HTH Otto
Sub SetRngs()
Dim First As Range
Dim Last As Range
Dim c As Long
c = 1
Set First = Range("A2")
Do
If First.Value < First.Offset(c).Value Then
Set Last = First.Offset(c - 1)
If Not IsEmpty(First.Value) Then _
Range(First, Last).Name = First.Value & "Name"
Set First = Last.Offset(1)
c = 1
Else
c = c + 1
End If
Loop Until IsEmpty(First.Value) = True
End Sub
wrote in message
ps.com...
I am trying to create multiple ranges in one column using VBA.

I have a set of data in one column and I want to create ranges for each
value, eg

Data:
A
A
A
B
B
C
C
C

I would like a range for A, a range for B, a range for C etc

Thanks
Neil



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
Sorting Data From One Column into Multiple Columns Justin Hoffmann Excel Worksheet Functions 2 July 12th 06 04:15 PM
PivotTable - Multiple Consolidation Ranges Alan Excel Worksheet Functions 1 March 10th 06 01:54 PM
Change a Column list into multiple rows & columns angelface Excel Worksheet Functions 3 January 28th 06 01:23 AM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Multiple Functions In One Column roy.okinawa Excel Worksheet Functions 4 December 20th 05 09:50 PM


All times are GMT +1. The time now is 06:47 AM.

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

About Us

"It's about Microsoft Excel"