Find first instance of a string then "group" all remaining rows together

john69

New Member
Joined
Dec 19, 2010
Messages
11
Hello all -

What I want to accomplish is to group the City A's in rows 5 & 6 to 2 & 3 by finding the first instance of a string in the text column and then finding the remaining ones in the rest of the range and moving the entire row(s) up. Once it groups CITY A, then it will search for CITY B, group all of them, then CITY C, etc.
There can be up to several unique text values in a list and up to 600-700 rows of total data.

I hope I have explained it well enough. Thank you in advance for you consideration in helping me with this one!

Before:
ID (col F)
TEXT (col N)
1CITY A
2CITY B
3CITY C
4CITY A
5CITY A

<tbody>
</tbody>

After:
IDTEXT
1CITY A
4CITY A
5CITY A
2CITY B
3CITY C

<tbody>
</tbody>
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
From the information given, it seems the simplest answer is to select all the data you want arranged this way and sort it by column N.
 
Upvote 0
From the information given, it seems the simplest answer is to select all the data you want arranged this way and sort it by column N.

Thank you for the reply, but it really isn't that simple. The actual list is for a production line that produces product starting from the west coast and with the exception of grouping the cities together, the first instance of each city must remain where its at and I must move the remaining ones "up" to the first one.
If I just sort by the city, then I lose the "first instance" of each city for production. In a way, it would be like taking a copy of (the first instance) of each unique city name, then inserting the remainder of them just below (along with entire row of data). I apologize I can't explain it any better.
 
Upvote 0
...the first instance of each city must remain where its at and I must move the remaining ones "up" to the first one.

Relative to what? Must it remain in a specific row on the sheet (and how will your copy-and-insert affect that?), or do you mean that it must still be where it is relative to the other production from that city?


...If I just sort by the city, then I lose the "first instance" of each city for production...

Not sure what you mean here. You can sort by city first, then by date/time to keep them in chronological order.


A few rows of data, fictionalized to protect your actual data, would probably clear things up. A small set showing what you start with and what you want to end with would be helpful.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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