Custom list

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
Good Morning everyone.
I think I have figured out how to ask my question that will help get the right type of answers. If you need more information please let me know and I thank you all in advance.
I have a large program that completes many things one of these is making a CSV file that gets loaded into another program to have it make a packet. Currently the packet that is made is fine with no issue but I need another packet in a different order. This in lies my issue the current macro that I use will only fine the first match and I need it to find all the matches. The macro listed below is one I got here awhile back and I tried to get it to work to generate the list in the correct order and it works until I have similar files. My question is what can I use to achieve the same result but get all the files listed in the correct order?
current macro:
VBA Code:
    For Each rng In WS2.Range("C2", WS2.Range("C" & WS2.Rows.Count).End(xlUp))
        Set fnd = WS1.Range("A:A").Find(rng, LookIn:=xlValues, lookat:=xlPart)
        If Not fnd Is Nothing Then
            fnd.Offset(, 1) = rng.Offset(, 1)
        End If
    Next rng
This macro returns looks at the list of file names on another sheet and matches it to the matching path and then returns a number from the same list.

Example File names Example order of files
C:\Users\Toast\Desktop\RM9006.pdf3
C:\Users\Toast\Desktop\trial_balance3763092.pdf2
C:\Users\Toast\Desktop\logo_folio3763012.pdf3
C:\Users\Toast\Desktop\IH Guest by Tax_938293.pdf1
C:\Users\Toast\Desktop\001_692159.pdf4
C:\Users\Toast\Desktop\logo_folio5769112.pdf3
C:\Users\Toast\Desktop\RM31.pdf3
With this example the macro would return a number for RM9006 & Folio 3763012 (The first ones in the list) but nothing for the other similar files.
I Understand that I haven't specifically defined these as I have with the other files because they could be anything starting with "RM*.pdf" or "logo_folio*.pdf".
If I put them in the list another macro tries to name the file that causing issues.

If anyone as a way I can get a macro to watch all the files to a number or other was I can solve it I would be so grateful.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,141,072
Messages
5,704,128
Members
421,328
Latest member
CBL

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
Top