|
本来是想把截图里的这一行(就是标题行)赋值给所有在该文件夹里的每一个xls文件里第一行(即每一个文件前十五个单元格),
但是运行之后无变化,求大佬们帮忙看一下哪里出现了问题。
Sub 遍历标题第一行()
Dim MyFile As String
Dim Arr(100) As String
Dim count As Integer
MyFile = Dir("C:\Financial\08. Missing fapiao\Missing fapiao send VBA\Ceshi\ceshi2\" & "*.xls")
count = count + 1
Arr(count) = MyFile
Do While MyFile <> ""
MyFile = Dir
If MyFile = "" Then
Exit Do
End If
count = count + 1
Arr(count) = MyFile '将文件的名字存在数组中
Loop
For i = 1 To count
Workbooks.Open Filename:="C:\Financial\08. Missing fapiao\Missing fapiao send VBA\Ceshi\ceshi2\" & Arr(i) '循环打开Excel文件
Workbooks(Arr(i)).Sheets(1).Cells(1, 1) = "owner"
Workbooks(Arr(i)).Sheets(1).Cells(1, 2) = "Voucher#"
Workbooks(Arr(i)).Sheets(1).Cells(1, 3) = "VendorName"
Workbooks(Arr(i)).Sheets(1).Cells(1, 4) = "Total Amt with VAT"
Workbooks(Arr(i)).Sheets(1).Cells(1, 5) = "Pay Date"
Workbooks(Arr(i)).Sheets(1).Cells(1, 6) = "CM"
Workbooks(Arr(i)).Sheets(1).Cells(1, 7) = "Aging days"
Workbooks(Arr(i)).Sheets(1).Cells(1, 8) = "Description(Eng)"
Workbooks(Arr(i)).Sheets(1).Cells(1, 9) = "Description(Chi)"
Workbooks(Arr(i)).Sheets(1).Cells(1, 10) = "owner"
Workbooks(Arr(i)).Sheets(1).Cells(1, 11) = "Cost center"
Workbooks(Arr(i)).Sheets(1).Cells(1, 12) = "Expected receive date(CW)"
Workbooks(Arr(i)).Sheets(1).Cells(1, 13) = "付款单号"
Workbooks(Arr(i)).Sheets(1).Cells(1, 14) = "采购订单号"
Workbooks(Arr(i)).Sheets(1).Cells(1, 15) = "received or not"
ActiveWorkbook.Close savechanges = True '关闭打开的文件
Next
End Sub
|
|