提供源数据文件名、路径、格式
追问已经私信给你了
追答Const bk1 = "接单.xlsx"
Sub 矩形3_Click()
Dim i&, j&, d As Object, wb As Workbook
nm = [y2]
Set d = CreateObject("scripting.dictionary")
i = 9
Do While Cells(i, 3) <> ""
d(Cells(i, 3).Text) = ""
i = i + 1
Loop
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & bk1)
ThisWorkbook.Activate
j = 9
with wb.Sheets(1)
Do While .Cells(j, 20) <> ""
If .Cells(j, 20) = nm And .Cells(j, 28) > 0 Then
If Not d.exists(.Cells(j, 3).Text) Then
d(.Cells(j, 3).Text) = ""
Cells(i, 2) = Cells(i - 1, 2) + 1
Cells(i, 3) = .Cells(j, 3)
Cells(i, 4) = .Cells(j, 6)
Cells(i, 5) = .Cells(j, 7)
Cells(i, 6) = .Cells(j, 10)
i = i + 1
End If
End If
j = j + 1
Loop
wb.Close false
End Sub
追问非常非常感谢!已基本实现我需要的功能,有两个小小问题:
1,接单.xlsx如果打开后更改了数据没有保存,会被关闭。能否无能打开或关闭状态都能调用数据?
2、第9行必需保持有数据。
另外我上传的文件夹里还有一个客户进度跟踪表,请再写个类似的代码,将生产进度信息调入。
再次感谢!
追答超字数,已发私信
本回答被提问者采纳