Search from master list

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
I have an workbook I’m having an issue with on the first sheet1 I have a list of current names inA, on the second sheet2 I have the master list with search names inA and correct names inC.
Here is my issue:
Sheet1 inA i get a list of names these have unique text in the name.
Sheet2 inA i have the same list without unique identity text but matches part of the name from Sheet1.
i have tried Index & Match and Vlookup but i get mostly right answers and some wrong ones. For example if I put yum.pdf on sheet1 it’s returning a name that it shouldn’t. (Yum isn’t in master list)
i have also tried search but it can’t look in a different sheet.
Basically I want this to happen:
if part of the text in A1 on sheet1 match text from range on Sheet2 return info from same row two columns to the right where text was found. And so on down list on sheet1
DFFAE351-506E-4612-9092-30637E63A2C1.jpeg
6000BAC5-2AAD-4B53-A16A-994A8124E57B.jpeg
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this macro:
VBA Code:
Sub CompareNames()
    Application.ScreenUpdating = False
    Dim Rng As Range, WS1 As Worksheet, WS2 As Worksheet, desWS As Worksheet, fnd As Range
    Set WS1 = Sheets("Sheet1")
    Set WS2 = Sheets("Sheet2")
    For Each Rng In WS2.Range("A2", WS2.Range("A" & 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(, 2)
        End If
    Next Rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
That has worked the only thing I had to do was set a macro to sort columnA on sheet1 Z-A then run this and it pulls all of the names thank you for your help it was making me crazy for days trying to figure it out.
Thank you again!
 
Upvote 0
How do i get this macro to return the value to the right?
When i step through it it is looking like it is matching the correct names but is not returning a value to the right
VBA Code:
Sub CompareNames()
    Application.ScreenUpdating = False
    Dim Rng As Range, WS1 As Worksheet, WS2 As Worksheet, desWS As Worksheet, fnd As Range
    Set WS1 = Sheets("Temp")
    Set WS2 = Sheets("Data List")
    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(, 2)
        End If
    Next Rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
The macro was based on the screen shots in your original post. That data had the search name in column A. The revised macro you posted has the search name in column C. Use the XL2BB add-in (icon is in the menu) to post screen shots of your actual data.
 
Upvote 0
This is the first page like the one before:
exceltest1 (Working)0.xlsm
ABCDEFGH
1Current NameNew NameFolder PathF:\Test\auto
2Untitled_20200206_023255.pdfDaily(scanned).pdf
3trial_balance3763092.pdfTrial Balance.pdf
4test1.pdf
5taxexempt3762977.pdfGuest by Tax.pdf
6stat_dmy_seg3763091.pdfMarket Code.pdf
7nacc_authorization3762976.pdf
8ihg_paidout_receipt_logo3762987.pdfPaid Out(Other).pdf
9ihg_logo_folio3763012.pdf
10hkooobyreason3762986.pdfOut of Order.pdf
11guest_ledger3762979.pdfGuest Ledger.pdf
12gl_trial_balance3763090.pdfGuest Trial Balance.pdf
13giratevariance3762988.pdfRate Variance.pdf
14gi_c_h3762978.pdfGuest -in COMP.pdf
15gi_authlimit3762985.pdfCredit Limit alltypes.pdf
16finpayments3762982.pdfCashier Aud.pdf
17finopbalall3762980.pdfOpen Balance.pdf
18finjrnlbytrans3762981.pdfJournal by TRA.pdf
19deposit_ledger3762983.pdfDeposit Ledg.pdf
20creditcard_history3762975.pdfCredit Card History.pdf
21artransfer3762989.pdf
22aragingdet3762984.pdf
23013_677487.pdfGuest Ledger Detail.pdf
24010_657038.pdfPaid Out.pdf
25003_428525.pdfManager Report.pdf
26002_595993.pdfNew Trial Balance.pdf
27001_692159.pdfTitle.pdf
28
Home

This is the master list I need to pull the numbers from. It is similar to the one before but now has the final order number listed for each file:
exceltest1 (Working)0.xlsm
BCD
1Example NameCorrect NameFinal Order
2artransfer3762989.pdfAR Settlement.pdf15
3finpayments3762982.pdfCashier Aud.pdf20
4011_194372.pdfCashier Audit.pdf20
5creditcard_history3762975.pdfCredit Card History.pdf7
6gi_authlimit3762985.pdfCredit Limit alltypes.pdf9
7Untitled_20200206_023255.pdfDaily(scanned).pdf2
8deposit_ledger3766421.pdfDeposit Ledg.pdf12
9depled_321427.pdfDeposit Ledger.pdf12
10detaging_053783.pdfDetailed Aging.pdf14
11gi_c_h3762978.pdfGuest -in COMP.pdf21
12taxexempt3762977.pdfGuest by Tax.pdf16
13gihcomp_506317.pdfGuest COMP.pdf21
14013_677487.pdfGuest Ledger Detail.pdf18
15guest_ledger3762979.pdfGuest Ledger.pdf19
16gl_trial_balance3763090.pdfGuest Trial Balance.pdf17
17finjrnlbytrans3762981.pdfJournal by TRA.pdf3
18003_428525.pdfManager Report.pdf4
19manager_report3766426.pdfManager Report.pdf4
20stat_dmy_seg3763091.pdfMarket Code.pdf11
21002_595993.pdfNew Trial Balance.pdf5
22024_492359.pdfNight Auth.pdf8
23finopbalall3762980.pdfOpen Balance.pdf10
24hkooobyreason3762986.pdfOut of Order.pdf22
25010_657038.pdfPaid Out.pdf23
26ihg_paidout_receipt_logo3762987.pdfPaid Out(Other).pdf23
27giratevariance3762988.pdfRate Variance.pdf13
28001_692159.pdfTitle.pdf1
29trial_balance3763092.pdfTrial Balance.pdf6
30ihg_logo_folio3763012.pdf
Data List

Here is the temp list that is created to export as CSV
exceltest1.xlsm
AB
1LocationFinal Order#
2F:\Test\self\Aging.pdf
3F:\Test\self\ARset.pdf
4F:\Test\self\Cashier.pdf
5F:\Test\self\Comp.pdf
6F:\Test\self\CRE all types.pdf
7F:\Test\self\CRE History.pdf
8F:\Test\self\Deposit.pdf
9F:\Test\self\GLD.pdf
10F:\Test\self\Guest ledger.pdf
11F:\Test\self\Guest tax.pdf
12F:\Test\self\Guest Trial.pdf
13F:\Test\self\Jou.pdf
14F:\Test\self\Manager.pdf
15F:\Test\self\Market.pdf
16F:\Test\self\New Trial.pdf
17F:\Test\self\Night Auth.pdf
18F:\Test\self\Openbal.pdf
19F:\Test\self\Out of Order.pdf
20F:\Test\self\Paid.pdf
21F:\Test\self\Ratevar.pdf
22F:\Test\self\RM9006.pdf
23F:\Test\self\Title.pdf
24F:\Test\self\Trial.pdf
Temp

(I know file names don't match it was for testing only when all done it will be in one single file)
Basically I need the Final Order numbers to show up in the Temp page next to their right name to be able to custom sort in a fixed order every time. before I export
I have also attached the code that makes the temp sheet sit helps
VBA Code:
Sub ListAllFileedit()
    Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Dim sPath As String
Dim lrA As Long
    Dim lrB As Long
    Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets.Add
ActiveSheet.Name = "Temp"
Sheets("Home").Activate
'Get the folder object associated with the directory
sPath = ActiveSheet.Range("H1")
Set objFolder = objFSO.GetFolder(sPath)
Sheets("Temp").Activate
ws.Cells(1, 1).Value = "Location"
ws.Cells(1, 2).Value = "Final Order#"
    'ws.Cells(1, 3).Value = "The file Size is:"
    'Loop through the Files collection
For Each objFile In objFolder.Files
'If objFile.Name Like "*.pdf" Then
lrA = Range("A" & Rows.Count).End(xlUp).Row
'lrB = Range("B" & Rows.Count).End(xlUp).Row
ws.Range("A" & lrA + 1).Value = objFile.Path
'The line below is where I need to add the code to fill final order #
'ws.Range("B" & lrB + 1).Value = objFile.DateLastModified
'ws.Range("C" & lrB + 1).Value = objFile.Size
'End If
Next
'ws.Cells(1, 1).delete
'Clean up!
Stop
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("Temp").Copy
ActiveWorkbook.SaveAs Filename:=objFolder & "\" & "Temp.csv", FileFormat:=xlCSV
ActiveWorkbook.Close True
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
Call delete
End Sub

I thank you again for all the help you have provided.(y):)?
 
Upvote 0
Looking at your macro in Post #5, it looks like you want to compare column C in Data List to column A in Temp and return column D of Data List to column B of Temp. If this is correct, what is the purpose of the Home sheet? Based on the latest screenshots, could you please explain again referring to specific sheets and cells, which columns you want to match. Can you post a screen shot of the Temp list showing the expected results in column B?
 
Upvote 0
I apologize for the confusion the home page is not important for what i need to do.
Here is the data list i need to pull the numbers from:
exceltest1 (Working).xlsm
ABCD
1Search NameExample NameCorrect NameFinal Order
2trial_balancetrial_balance3763092.pdfTrial Balance.pdf6
3001_001_692159.pdfTitle.pdf1
4giratevariancegiratevariance3762988.pdfRate Variance.pdf13
5010_010_657038.pdfPaid Out.pdf23
6ihg_paidout_receipt_logoihg_paidout_receipt_logo3762987.pdfPaid Out(Other).pdf23
7hkooobyreasonhkooobyreason3762986.pdfOut of Order.pdf22
8finopbalallfinopbalall3762980.pdfOpen Balance.pdf10
9024_024_492359.pdfNight Auth.pdf8
10002_002_595993.pdfNew Trial Balance.pdf5
11stat_dmy_segstat_dmy_seg3763091.pdfMarket Code.pdf11
12003_003_428525.pdfManager Report.pdf4
13manager_reportmanager_report3766426.pdfManager Report.pdf4
14finjrnlbytransfinjrnlbytrans3762981.pdfJournal by TRA.pdf3
15gl_trial_balancegl_trial_balance3763090.pdfGuest Trial Balance.pdf17
16guest_ledgerguest_ledger3762979.pdfGuest Ledger.pdf19
17013_013_677487.pdfGuest Ledger Detail.pdf18
18gi_c_hgi_c_h3762978.pdfGuest -in COMP.pdf21
19gihcomp_gihcomp_506317.pdfGuest COMP.pdf21
20taxexempttaxexempt3762977.pdfGuest by Tax.pdf16
21detaging_detaging_053783.pdfDetailed Aging.pdf14
22depled_depled_321427.pdfDeposit Ledger.pdf12
23deposit_ledgerdeposit_ledger3766421.pdfDeposit Ledg.pdf12
24Untitled_Untitled_20200206_023255.pdfDaily(scanned).pdf2
25gi_authlimitgi_authlimit3762985.pdfCredit Limit alltypes.pdf9
26creditcard_creditcard_history3762975.pdfCredit Card History.pdf7
27011_011_194372.pdfCashier Audit.pdf20
28finpaymentsfinpayments3762982.pdfCashier Aud.pdf20
29artran_artransfer3762989.pdfAR Settlement.pdf15
30ihg_logo_folioihg_logo_folio3763012.pdf25
Data List

I need the number to the right of the file name
exceltest1 (Working).xlsm
AB
1LocationFinal Order#
2F:\Test\NEW\auto - Copy\Trial Balance.pdf6
3F:\Test\NEW\auto - Copy\Title.pdf1
4F:\Test\NEW\auto - Copy\Rate Variance.pdf13
5F:\Test\NEW\auto - Copy\Paid Out.pdf23
6F:\Test\NEW\auto - Copy\Out of Order.pdf22
7F:\Test\NEW\auto - Copy\Open Balance.pdf10
8F:\Test\NEW\auto - Copy\Night Auth.pdf8
9F:\Test\NEW\auto - Copy\New Trial Balance.pdf5
10F:\Test\NEW\auto - Copy\Market Code.pdf11
11F:\Test\NEW\auto - Copy\Manager Report.pdf4
12F:\Test\NEW\auto - Copy\Journal by TRA.pdf3
13F:\Test\NEW\auto - Copy\ihg_logo_folio3766175.pdf
14F:\Test\NEW\auto - Copy\ihg_logo_folio3765986.pdf
15F:\Test\NEW\auto - Copy\Guest Trial Balance.pdf17
16F:\Test\NEW\auto - Copy\Guest Ledger.pdf19
17F:\Test\NEW\auto - Copy\Guest Ledger Detail.pdf18
18F:\Test\NEW\auto - Copy\Guest COMP.pdf21
19F:\Test\NEW\auto - Copy\Guest by Tax.pdf16
20F:\Test\NEW\auto - Copy\Detailed Aging.pdf14
21F:\Test\NEW\auto - Copy\Deposit Ledger.pdf12
22F:\Test\NEW\auto - Copy\Daily(scanned).pdf2
23F:\Test\NEW\auto - Copy\Credit Limit alltypes.pdf9
24F:\Test\NEW\auto - Copy\Credit Card History.pdf7
25F:\Test\NEW\auto - Copy\Cashier Audit.pdf20
26F:\Test\NEW\auto - Copy\AR Settlement.pdf15
27F:\Test\NEW\auto - Copy\Adjustment Log.pdf
Temp

This is how i need the numbers to show up on the temp sheet
This is important because when i short the temp list by number small to large it will always list the file locations in the correct order.
I hope that helps any questions please ask
 
Upvote 0
Basically i need to match a cell in column a on Temp sheet to a matching value in Data List column c and return the value(to the right) from Column D to the Temp sheet column B Im defiantly having trouble explaining it but i hope you can understand with the help of the pictures
 
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

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