VBA code to find a match then sort data in order based on two separate columns

mustacheman

New Member
Joined
May 27, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
We are trying to move inventory from one slot to the next, and do them in sequential order to save footsteps. I'm trying to build the worksheet to plan the moves. Some slots don't have exact matches, so if that's the case we just start back at the beginning of the data list. I was trying to create a macro for this to move the data in a new tab, but I'm getting errors stuck in my loop and variables. My other idea was to keep moving a row at a time and then resorting the table each time but then the variable I set up the numbers are changing after the sorting. Can someone please help?

Here's how it would work. If you look at the attached image

Move Row 2 into new tab. Look at column H to see the prior slot number. Go to that slot number on column I on the workbook. Move that row to the new data set tab. Look at H again to see the next slot number and repeat. (So if no match in column H just go back to the top of the data and start over.


From the image you can see I already did it manually the first 10 rows or so. Column H was slot FG14910 and I found it in column I, so moved that to the next row. Then No match for Fd13310 or FD13710. Then I find a match for FD18210 on the 4th row, so thats next item for the 5th row.

Thanks Mustacheman
 

Attachments

  • macrosort.jpg
    macrosort.jpg
    200.9 KB · Views: 47

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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