每都都會連同舊的資料一起重抓重跑,時間秏費不少
我想要的結果是之前執行後的舊資料會留著,每當我有一筆新資料進來時,就只要跑新的資料新增就好
因為我vb不好,沒法子像板大一樣,可以寫出比對資料庫裡的data,只把新進來的data抓出來,
後來剛吃晚餐時,突然想到另一個解決方式
我將新的data放進另一個新的資料夾,然後不要消除每一行的資料,即執行以下程式碼
Option Explicit
Sub Ex()
Dim Ex_Path As String, Ex_File As String, Ex_Date As String, Ex_Wb As Workbook
Dim Rng As Range, Ex_Row As Integer, i As Integer ', Ar() As String, Ex_Name As String
Ex_Path = "C:\Documents and Settings\gkld\桌面\my kp\資料庫\新資料夾\"
Ex_File = Dir(Ex_Path & "A112*ALL_1.csv")
If Ex_File = "" Then
MsgBox "沒有 A112*ALL_1.csv"
Exit Sub
End If
Application.ScreenUpdating = False
'Ar = Array("台泥", "亞泥", "嘉泥", "幸福", "信大", "東泥")
For i = 1 To 7
'** Name 是VBA所用的關鍵字串,避免使用為變數名稱.
' If i = 1 Then Ex_Name = "台泥"
' If i = 2 Then Ex_Name = "亞泥"
' If i = 3 Then Ex_Name = "嘉泥"
' If i = 4 Then Ex_Name = "環泥"
' If i = 5 Then Ex_Name = "幸福"
' If i = 6 Then Ex_Name = "信大"
' If i = 7 Then Ex_Name = "東泥"
With Sheets(i) '依工作表索引值指定工作表
'****工作表名稱 在活頁簿視窗排序如是依IF i=1如此順序***
'***那就不需這些IF i=1 ...........