Sorting Multiple Columns to Match/Align with Data in Column A

PSLAV

New Member
Joined
May 16, 2014
Messages
4
Scenario:

- I have Column A filled with roughly 3000 product IDs. (These are the products I want to update)
- I have Column B filled with roughly 45,000 product IDs (These are all of my product IDs, in which the 3000 or so from Column A are in...)
- Columns C - AZ have data that is connected with the product IDs in column B (the product name, description, price, etc)


I need to find a way to sort the data in columns B-AZ to match/align with the product IDs in Column A, while keeping the information connected to the product IDs intact.

Hopefully I would then be able to scroll down to where my Column A ends, and can then delete the rest of the data in B-Z, leaving me with organized, matched data for my 3000 product IDs.


I hope this makes sense and is clear...I have tried VLookup and IF statements, but I DO NOT want just another column that displays if the data is in Column B, (I already know it is) I need all of the information to be sorted according to Column A's matching Column B's product IDs.


Thank you for your help! I desperately need it!

-PSLAV

Edit: Here is an extremely simplified version of what I am trying to accomplish...
Screenshot%202014-05-16%2013.48.03.png


And want it to look like this
Screenshot%202014-05-16%2013.50.13.png
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I gave it a shot, I know you said you tried vlookup's already but I'm still confused why that doesn't solve your problem. This code assumes you have headers and will put the results in columns E and F. Here's what the output is. Still sorta new to vba so I'm sure there's a better way to go about it.

1
2
This is with 2
3
This is with 3
4
This is with 4
5
This is with 5
6
This is with 6
7
This is with 7
8
This is with 8
9
This is with 9
10
11
12
This is with 12
13
This is with 13
14
This is with 14

<tbody>
</tbody>

<tbody>
</tbody>

Code:
Sub SortMatch()


Dim LastRow As Integer


LastRow = Range("B:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


For i = 2 To LastRow
    Range("E" & i) = Range("A" & i)
    Range("F" & i).FormulaR1C1 = "=vlookup(RC1,R2C2:R" & LastRow & "C3,2,False)"
  Next i


Range("F1:F" & LastRow).SpecialCells(xlCellTypeFormulas, xlErrors).Clear


End Sub
 
Upvote 0
I gave it a shot, I know you said you tried vlookup's already but I'm still confused why that doesn't solve your problem. This code assumes you have headers and will put the results in columns E and F. Here's what the output is. Still sorta new to vba so I'm sure there's a better way to go about it.

1
2This is with 2
3This is with 3
4This is with 4
5This is with 5
6This is with 6
7This is with 7
8This is with 8
9This is with 9
10
11
12This is with 12
13This is with 13
14This is with 14

<tbody>
</tbody>

<tbody>
</tbody>

Code:
Sub SortMatch()


Dim LastRow As Integer


LastRow = Range("B:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


For i = 2 To LastRow
    Range("E" & i) = Range("A" & i)
    Range("F" & i).FormulaR1C1 = "=vlookup(RC1,R2C2:R" & LastRow & "C3,2,False)"
  Next i


Range("F1:F" & LastRow).SpecialCells(xlCellTypeFormulas, xlErrors).Clear


End Sub


Thank you I will absolutely try this and let you know if it works. I appreciate it!

Vlookup's don't solve my problem (I think), because I am not trying to put results in any new column/cells. I am trying to sort/filter Column B (And all data in columns C:AZ that coincides with it) by what I put in Column A.

Like if I could simply select all columns except A, sort by "matching" column B with column A, my problem would be solved.
 
Upvote 0
RadioME...I could not get this code to work for me...Kept coming up with error codes.

Does no one know how to sort a bunch of data to line up with another column? (ie. not alphabetically/A-Z but based on what is in column A?)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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