advanced column filtering

cal6404

New Member
Joined
Jul 5, 2018
Messages
3
Hi, I have many columns in excel that I need have the rows within each sorted. Values in column B have been duplicated in column E at but they aren't in the same row. I need to match the rows from column B and E such that each row in B has the corresponding cell from column E below it. I would really appreciate the help.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Welcome to the MrExcel board!

Could you post a small set of dummy sample data and the the expected results? My signature block below has a link with options for posting sample data that we can copy/paste to test with.
 
Upvote 0
Hi, sorry it's taken me a while to get back to you. Here is a small example of the before sorting and the result that I want after sorting. I need the Object ID value (say P00021) to be above the Unit (say P00021). Basically the rows with the corresponding Object ID and Unit values are scattered throughout my data and I need to have them shown as one above the other for the entire set of data.

Before sorting
TypeObject ID DescriptionUnit
AAGITAT0086AGITATOR UNITAG00091
PAREA455AmmoniumArea
PP00021Pumping Unit 6
PAG00091AGITATOR - TOP MOUNTED
APUMP11001CentrifugalP00021
After sorting
TypeObject ID DescriptionUnit
PP00021Pumping Unit 6
APUMP11001CentrifugalP00021
PAG00091AGITATOR - TOP MOUNTED
AAGITAT0086AGITATOR UNITAG00091
PAREA455AmmoniumArea

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Try this with a copy of your workbook. It uses columns B & D as your last post seemed to have that, rather than B & E.
If you need B & E and can't modify the code, post back.
Code:
Sub Special_Sort()
  Dim lr As Long
  
  lr = Range("A" & Rows.Count).End(xlUp).Row
  With Range("A2:E" & lr)
    .Columns(5).Formula = Replace("=IF(ISNUMBER(MATCH(B2,D$2:D$#,0)),ROWS(E$2:E2),IFERROR(MATCH(D2,B$2:B$#,0)+0.5,ROWS(B$2:B$#)+1))", "#", lr)
    .Sort Key1:=.Columns(5), Order1:=xlAscending, Header:=xlNo
    .Columns(5).ClearContents
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,179
Members
448,948
Latest member
spamiki

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