如下程式碼運作是開啟A檔案 與B檔案 , 執行程式後 會將B檔案的資料匯入A檔案指定的工作表欄位
With Workbooks(i).Sheets(1)
If .Range("A" & title_row).Value Like "A*" And .Range("D" & title_row).Value Like "B*" And .Range("E" & title_row) Like "C*"
Set xS = Workbooks(i).Sheets(1)
Dim UType%
Sub 匯入()
Dim xFile$, x As New Application, xB As Workbook, xS As Worksheet
Dim RepSht As Worksheet, xR As Range, xLab As Range, xAddress$
Set RepSht = Sheets("A")
Application.ScreenUpdating = False
RepSht.UsedRange.EntireRow.Delete
Dim currentPKG, currentDevice, whichFirst As String
Dim index As Integer
Dim hasReport As Boolean
title_row = 1
hasReport = False
For i = 1 To Workbooks.Count
With Workbooks(i).Sheets(1)
If .Range("A" & title_row).Value Like "A*" And .Range("D" & title_row).Value Like "B*" And .Range("E" & title_row) Like "C*" Then
Set xS = Workbooks(i).Sheets(1)
hasReport = True
i = Workbooks.Count + 1
End If
End With
Next i
If hasReport = False Then MsgBox "找不到檔案! ": Exit Sub