- 帖子
- 315
- 主題
- 51
- 精華
- 0
- 積分
- 367
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2015-9-29
- 最後登錄
- 2021-10-12
|
9#
發表於 2019-6-2 11:16
| 只看該作者
本帖最後由 Airman 於 2019-6-2 11:18 編輯
回復 7# Scott090
Scott090大大 :
測試報告:
咖啡色字=新增的貴解程式碼
藍色字=選擇性執行的程式碼
需求=檔案名稱有均值時,則執行藍色字的程式碼;如果檔案名稱內沒有均值時,就跳過藍色字的程式碼(即不執行)。
目前以下列的程式碼=無論檔案名稱內沒有或沒有均值的文字,全部都有執行藍色字的程式碼。
請問 : 要如何修正?
謝謝您^^
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
Columns("A:AX").Font.Name = "Arial"
Columns("A:AX").HorizontalAlignment = xlCenter
Columns("A:AX").EntireColumn.AutoFit
[B2].Select
ActiveWindow.FreezePanes = True
ActiveWindow.Zoom = 75
.Close True
End With
Kill Path & "\" & A
A = Dir
Loop
End Sub |
|