Sorting with merged cells

kmjones

New Member
Joined
Jun 15, 2005
Messages
44
I have many many columns and rows. They are organized in such a way that there is 5 or 6 rows merged in the first column almost like a label. The following columns contain the unmerged rows and are like a breakdown of information about the 1st column's merged "label" If that makes sense! I would like to alphabetically sort these rows by the merged label while keeping the other columns that are a breakdown of that label with them. If you can help at all!!! PLEASEEEE let me know! thanks so much!

ie:

1 hot supply
Label 4 red converter
3 cold produce


3 blue supply
Label2 6 hot supply
5 green red
8 pink blue


I want to sort the "labels" alphabetically while still keeping the information in the following columns with that specific "label"

thanks!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Unfortunately, merged cells cause many problems, especially with sorting. For this and other reasons, it is recommended that you avoid using Merged Cells.

There are other alternatives, such as centering across cells, which should give you the sane effect without the problems.

Check out this link for instructions on how to do that.
http://www.mrexcel.com/board2/viewtopic.php?t=76249
 
Upvote 0
I tried that. Didn't work. If I take out the merged cells, how would I sort this column and keep all the following columns that i want with it? Like if column a is to be sorted alphabetically and but rows 1-5 go with the word is A1 and then the word in d6 is moved to a1 when sorted, how do i get the information in the 5 rows to move with D6 when it is moved to A1 and have the info in the 5 rows referrring to A1 move with it when it is sorted ?
 
Upvote 0
Can you post 2 screen shots please, just so we can see the pattern of what you have now, and then how you want it to look after the sort is executed. The example in your first post is too inconclusive. You were talking about "5 or 6" rows of data but you only show 3 or 4 rows of data in your example. Also, point out any patterns such as if the record sets are always separated by an empty row, and if empty really means empty, not just blank-looking cells with spacebars or null string formulas, etc.

Also, you are posting this question on more than one thread:
http://www.mrexcel.com/board2/viewtopic.php?t=76249

Please stick to one thread or the other.
 
Upvote 0
example.xls
ABCD
1Oneaaa
2aaa
3
4Twobbb
5bbb
6bbb
7
8Threeccc
9ccc
10ccc
11ccc
12
13Fourddd
14
15
16
17
18Fourddd
19
20Oneaaa
21aaa
22
23Threeccc
24ccc
25ccc
26ccc
27
28Twobbb
29bbb
30bbb
Sheet1


Here is an example of what I am looking to be able to do. As shown, the user can add and delete the number of rows that go with each main topic. Therefore, the code has to somehow be able to track that. Is this even possible?
 
Upvote 0
This is one way to do what you say you want.

Based on your screen shot, your data starts in row 1 and each section is separated by one empty row. Activate that sheet and run this macro from there...try it first on a copy of your workbook to make sure it does what you want.

This worked fine for me, tested no problem on xl2K3 xp.



Sub Test1()
With Application
.ScreenUpdating = False
.DisplayAlerts = False

Dim asn$, x&, Rowz&, Area As Range
asn = ActiveSheet.Name: Rowz = 0

Workbooks.Add 1
ThisWorkbook.Sheets(asn).Cells.Copy Cells
ThisWorkbook.Sheets(asn).Cells.Clear

Cells.UnMerge
Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(4).Formula = "=R[-1]C"
Columns(1).Value = Columns(1).Value
Columns(2).SpecialCells(4).EntireRow.Delete
Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo

For x = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If Cells(x, 1).Value <> Cells(x - 1, 1).Value Then Rows(x).Insert
Next x
Columns(1).SpecialCells(4).EntireRow.Clear

For Each Area In Columns(1).SpecialCells(2).areas
With Range(Area.Address)
If .Rows.Count > 1 Then
.Offset(1).Resize(.Rows.Count - 1).ClearContents
.VerticalAlignment = xlCenter
.Merge
End If
End With
Rowz = Rowz + Area.Rows.Count + 1
Next Area

Cells.Copy ThisWorkbook.Worksheets(asn).Cells
ActiveWorkbook.Close False

.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
 
Upvote 0
Still looking for help. I have update the spread I am workin on and the code doesnt quiet work. So, Below is an example of what I am looking to do.
 
Upvote 0
Book1
ABCDEFGHI
1
2Base4th8Abs75%cho00
3cho00
4Total00
5Cumm Total55
6LT:
7
8
9Audio
103rd8Abs75%jom00
11Total00
12Cumm Total1010
13LT:
14
15
16Ant/Spkr1Abs75%abc00
17abc00
18Total00
19Cumm Total1515
20LT:
21
22
23Back
242Abs70%asdf00
25asdf00
261stasdf00
27Total00
28Cumm Total2525
29LT:
30
Sheet1
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,545
Members
449,317
Latest member
chingiloum

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top