我的代码工作正常但我无法弄清楚如何让代码逐步执行单元格数组值以匹配工作表名称数组,然后如果值和工作表名称匹配则获取偏移单元格该表的价值。 如果找不到任何值,则转到下一个值/ Sheet。有人可以帮忙吗?。
Sub Data()
Dim wb1 As Workbook, wb2 As Workbook, sh1 As Worksheet, sh2 As Worksheet, mywb As String, LR As Long, c As Range, x As Range
Application.ScreenUpdating = False
mywb = "Part Description 2017.xlsx"
Workbooks.Open Filename:="C:\Users\Me\Desktop\Part Description 2017.xlsx"
ActiveWindow.Visible = False
Set wb1 = ActiveWorkbook
Set wb2 = Workbooks("Part Description 2017.xlsx")
Set sh1 = wb1.ActiveSheet
Set sh2 = wb2.Sheets("Customer Prefix")
Application.ScreenUpdating = False
LR = sh1.Cells(Rows.Count, 2).End(xlUp).row
For Each c In Range("B2:B" & LR)
Set x = sh2.Range("A:A").Find(c.Value, , xlValues, xlWhole)
If Not x Is Nothing Then
c.Offset(0, 1).Value = x.Offset(0, 1).Value
End If
Next
Set x = Nothing
Workbooks(mywb).Close False
Application.ScreenUpdating = True