If Debug.Print UBound(Split("???均值均值???", "均值")) Then GoTo 101
[B1:BK1].Clear
For j = 1 To 49 '均值
Cells(1, j + 1) = j
Next
101:
語法不對^^"作者: 准提部林 時間: 2019-6-2 09:52
Sub TEST()
Dim P$, F$, A$
P = ThisWorkbook.Path
Application.ScreenUpdating = False
Do
If F = "" Then F = Dir(P & "\*.csv") Else F = Dir
If F = "" Then Exit Do
A = Replace(Replace(F, "基準日:", ""), ".csv", "")
With Workbooks.Open(P & "\" & F)
If InStr(A, "均值") Then
[B1:BK1].Clear
For j = 1 To 49: Cells(1, j + 1) = j: Next
End If
If InStr(A, "總表") Then [A:A].NumberFormatLocal = "yyyy/mm/dd" '總表-日期-固定長度較好檢視
[B1:AX1].NumberFormatLocal = "00"
With [B1:AX1].Font: .Bold = True: .Size = 14: .ColorIndex = 5: End With
With [A:AX]
.Font.Name = "Arial"
.HorizontalAlignment = xlCenter
.EntireColumn.AutoFit
End With
[B2].Select
With ActiveWindow: .FreezePanes = True: .Zoom = 75: End With
.SaveAs Filename:=P & "\" & A & ".xls", FileFormat:=xlNormal, CreateBackup:=False
.Close 0
End With
Kill P & "\" & F
Loop
End Sub
Sub Ex()
Dim Path As String, A As String, j%
Path = ThisWorkbook.Path '請修改為你的資料夾
A = Dir(Path & "\*.CSV")
Do While A <> ""
Name Path & "\" & A As Path & "\" & Replace(A, "基準日:", "")
A = Replace(A, "基準日:", "")
With Workbooks.Open(Path & "\" & A)
.SaveAs Filename:=Path & "\" & Replace(A, ".csv", ".xls"), FileFormat:=xlNormal
If UBound(Split("???均值均值???", "均值")) > 1 Then [B1:BK1].Clear
For j = 1 To 49 '均值
Cells(1, j + 1) = j
Next End If
With [B1:AX1]
.Font.Bold = True
.Font.Size = 14
.NumberFormatLocal = "00"
.Font.ColorIndex = 5
End With