Code to merge set of rows

KORKIS2

Board Regular
Joined
Jun 5, 2015
Messages
143
I have code to search down a column for a range of rows now i need code to take that range and merge it all togeher in
 
Ok thats the right concept it organizes the whole row based on the alphabetical order based on Column A
The only thing I need different it for it to alphabetically organize based off the rows ranges that are pulled up from the array that is found and stored on the right. This is very close
Thank you for your help



This is what I got

51.0125Body 108.00108.0150512 851.012578
60.0125Body 82.0082.0150512 860.0125913
60.0125Body 83.00102.0150512 868.98751416
60.0125Body 103.00103.0150512
60.0125Body 109.00110.0150512
68.9875Body 106.00107.0150512
51.0125Head 105.00105.0150512
60.0125Head 104.00104.0150512
68.9875Head 111.00111.0150512

<colgroup><col width="64" span="13" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" span="13" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Ok this is very close it is sorting based on alphabetical order and using column B while moving the whole row.
However It still needs to pull from the Array bounds on the right to get the correct rows otherwise its sorts down the whole column instead of just the individual row ranges.

This is what I got from Mick Gs Code it is very close once again thank you for your time.

51.0125Body108.00108.0150512851.012578
60.0125Body82.0082.0150512860.0125913
60.0125Body83.00102.0150512868.98751416
60.0125Body103.00103.0150512
60.0125Body109.00110.0150512
68.9875Body106.00107.0150512
51.0125Head105.00105.0150512
60.0125Head104.00104.0150512
68.9875Head111.00111.0150512

<tbody>
</tbody>



This is what I'm looking for the final product to look like.

851.01378
860.013913
51.0125Body

105105150512


868.9881416
51.0125Head

108108150512
60.0125Body

8282150512






60.0125Body

83102150512






60.0125Head

103103150512






60.0125Head

104104150512






60.0125Head

109110150512
68.9875Body

106107150512






68.9875Head

111111150512

<tbody>
</tbody>
 
Last edited:
Upvote 0
Try this:-
NB:- The number of Bodies & Heads in your previous 2 List are not the same.???
Code:
[COLOR=Navy]Sub[/COLOR] MG16Jun20
[COLOR=Navy]Dim[/COLOR] Rng [COLOR=Navy]As[/COLOR] Range, Dn [COLOR=Navy]As[/COLOR] Range, n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] K [COLOR=Navy]As[/COLOR] Variant
[COLOR=Navy]Dim[/COLOR] Dic [COLOR=Navy]As[/COLOR] Object
[COLOR=Navy]Set[/COLOR] Rng = Range(Range("A7"), Range("A" & Rows.Count).End(xlUp))
 Rng.Resize(, 7).Sort Rng(1)
  [COLOR=Navy]Set[/COLOR] Dic = CreateObject("scripting.dictionary")
   Dic.CompareMode = vbTextCompare
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng
    [COLOR=Navy]If[/COLOR] Not Dn.Value = "" [COLOR=Navy]Then[/COLOR]
        [COLOR=Navy]If[/COLOR] Not Dic.Exists(Dn.Value) [COLOR=Navy]Then[/COLOR]
            Dic.Add Dn.Value, Dn
        [COLOR=Navy]Else[/COLOR]
            [COLOR=Navy]Set[/COLOR] Dic.Item(Dn.Value) = Union(Dic.Item(Dn.Value), Dn)
        [COLOR=Navy]End[/COLOR] If
    [COLOR=Navy]End[/COLOR] If
[COLOR=Navy]Next[/COLOR]
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] K [COLOR=Navy]In[/COLOR] Dic.keys
    Dic.Item(K).Offset(, 1).Sort Dic.Item(K).Offset(, 1)(1), xlAscending
[COLOR=Navy]Next[/COLOR] K


[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick
 
Upvote 0
It changes everytime and so does the range at which the rows for the body and head are in changes to. That's why I used an Array to search and print them out on the sheet to find the ranges to sort the head and body in.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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