Hello
Code below work perfectly for the exact match, would like some assistance to change it so that it finds any document that contains a string
Thanks
Code below work perfectly for the exact match, would like some assistance to change it so that it finds any document that contains a string
Code:
[COLOR=#E56717][FONT=Consolas][B]ub[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Run()[/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LRow [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]Integer[/B][/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LPath [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]String[/B][/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LExtension [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]String[/B][/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LContinue [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]Boolean[/B][/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Initialize variables
[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LContinue = [/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]True[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] LRow = 2[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] LPath = [/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"C:\Users\Sophia\Downloads\New folder\"[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] LExtension = [/FONT][/COLOR][COLOR=#800000][FONT=Consolas]".xl*"[/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Loop through all column A values until a blank cell is found
[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]While[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] LContinue[/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Found a blank cell, do not continue
[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]If[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Len(Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & CStr(LRow)).Value) = 0 [/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]Then[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] LContinue = [/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]False[/B][/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Check if file exists for part number
[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]Else[/B][/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Place "No" in column B if the file does NOT exist
[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]If[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Len(Dir(LPath & Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & CStr(LRow)).Value & LExtension)) = 0 [/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]Then[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"B"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & CStr(LRow)).Value = [/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"No"[/FONT][/COLOR]
[COLOR=#008000][FONT=Consolas]'Place "Yes" in column B if the file does exist
[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]Else[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"B"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & CStr(LRow)).Value = [/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"Yes"[/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]If[/B][/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]If[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] LRow = LRow + 1[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas] Wend[/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR]
Thanks