Private Sub CommandButton1_Click()
With ThisWorkbook
f = Replace(Replace(.Name, StrReverse(Val(StrReverse(Replace(.Name, ".xls", "")))), ""), ".xls", "")
'大大,上面這一步驟是??用好多層喔。發現抓到的是 f=麻辣1日
fs = Dir(f & "*.xls")
Do Until fs = ""
fs = Dir
i = i + 1
Loop
f = .Path & "\" & f & i + 1 & ".xls" '這一步,f=麻辣1日1.xls
.SaveCopyAs f
End With
End Sub
Private Sub CommandButton1_Click()
On Error Resume Next
ph = ThisWorkbook.Path & "\" '是抽取檔案的路徑 + \
f = ThisWorkbook.Name '是抽取檔案的名稱
i = 1
Do Until i > Len(f) Or Not IsEmpty(n)
n = Empty
n = CInt(Mid(f, i, 1))
If IsEmpty(n) Then k = k & Mid(f, i, 1)
Err.Clear
i = i + 1
Loop '這個loop是針對檔名做處理
p = Day(DateAdd("M", 1, Format(Date, "yyyy/m/1")) - 1)
'這個P是?????
For j = 2 To p '菜鳥如我,只會用 j = 2 to 31 為什麼用P呢
fs = ph & k & j & "日.xls" '設定檔名
If Dir(fs) = "" Then ThisWorkbook.SaveCopyAs fs '做防呆,沒有同檔名的話就新增,有同檔名就不新增以免覆蓋
Next
End Sub作者: Hsieh 時間: 2012-3-5 19:03