ivonsurf123
New Member
- Joined
- May 17, 2022
- Messages
- 14
- Office Version
- 2021
- Platform
- Windows
Hello,
Need help with my code, I want to find the wrong name in one spread sheet per example: "CRYOMAX COOLING SYSTEM CORP" (wrong) compare with a Master List: "CRYOMAX COOLING SYSTEM CORP."(Correct)
"SUN ELECTRONIC CO LTD" (Wrong) "SUN ELECTRIC CO.,LTD." (Correct) and Update the wrong names with the correct names that are in the Master List, Please Help, my code is missing something... Thank you.
Sub Update_Suppliers()
Dim wrkBK As Workbook
Dim DocFldr As String
Dim i, total, fRow As Integer
Dim found As Range
Dim w As Range
DocFldr = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Set wrkBK = Workbooks.Open(DocFldr & "\FY22_Monthly_analysis_Freight_in_out\SUPPLIERS_LIST.xlsx")
Application.ScreenUpdating = False
total = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To total
answer1 = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & i).Value
Set found = Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Columns("I:I").Find(what:=answer1) 'finds a match
If found Is Nothing Then
'Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Range("I" & i).Value = "NO MATCH"
Else
fRow = Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Columns("I:I").Find(what:=answer1).Row
Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Range("I" & fRow).Value = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & i).Value
End If
Next i
End Sub
Need help with my code, I want to find the wrong name in one spread sheet per example: "CRYOMAX COOLING SYSTEM CORP" (wrong) compare with a Master List: "CRYOMAX COOLING SYSTEM CORP."(Correct)
"SUN ELECTRONIC CO LTD" (Wrong) "SUN ELECTRIC CO.,LTD." (Correct) and Update the wrong names with the correct names that are in the Master List, Please Help, my code is missing something... Thank you.
Sub Update_Suppliers()
Dim wrkBK As Workbook
Dim DocFldr As String
Dim i, total, fRow As Integer
Dim found As Range
Dim w As Range
DocFldr = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Set wrkBK = Workbooks.Open(DocFldr & "\FY22_Monthly_analysis_Freight_in_out\SUPPLIERS_LIST.xlsx")
Application.ScreenUpdating = False
total = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To total
answer1 = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & i).Value
Set found = Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Columns("I:I").Find(what:=answer1) 'finds a match
If found Is Nothing Then
'Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Range("I" & i).Value = "NO MATCH"
Else
fRow = Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Columns("I:I").Find(what:=answer1).Row
Workbooks("Invoice rep. w. Chg Dtl June, 2022.xlsM").Worksheets("Copy").Range("I" & fRow).Value = Workbooks("SUPPLIERS_LIST.xlsx").Worksheets("SUPPLIERS_LIST").Range("B" & i).Value
End If
Next i
End Sub