VBA从另外一个工作薄中提取符合条件的数据

示例文件无法上传,请私信联系,谢谢!

第1个回答  2016-07-30
254103979 远程协助
第2个回答  2016-07-27
看看 数据样表把,看着繁琐,估计实际不难追问

http://pan.baidu.com/s/1gfFKJwn

第3个回答  2016-07-27
提供源数据文件名、路径、格式追问

已经私信给你了

追答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行必需保持有数据。
另外我上传的文件夹里还有一个客户进度跟踪表,请再写个类似的代码,将生产进度信息调入。
再次感谢!

追答

超字数,已发私信

本回答被提问者采纳
相似回答