回復 5#GBKEE
請教GBKEE
我參考您的
Sub Backup()
Dim FileDate As String
Set wb = ThisWorkbook
wb.Activate
If MsgBox("要備份資料嗎?", vbYesNo + vbQuestion, "訊息視窗") = vbYes Then
Application.DisplayAlerts = False
'With ActiveWorkbook.Sheets(Array(1, 3)).Copy 將此列改成紅色一列就不通嘞
With ActiveWorkbook.copy
FileDate = Format(Date, "yyyymmdd")
ActiveWorkbook.SaveAs FileName:=ThisWorkbook.Path & "\資料庫\" & FileDate & ".xls"
Application.EnableEvents = False
ActiveWorkbook.Close True
Application.EnableEvents = True
End With
Else
MsgBox "再見 !", vbOKOnly + vbInformation, "訊息視窗"
End If
Application.DisplayAlerts = True
End Sub
應如何 作
在wb中用vba
使原wb copy成 wb1 然後 wb1.close (這一段我不會,try很久嘞)
回wb 再做第二作者: yangjie 時間: 2014-6-22 23:22
回復 7#yangjie
感謝GBKEE
我參考這次與前13.14頁的檔案複製與sheets另存新檔
我的問題解決了
Sub Backup()
Dim FileName1 As String
Set wb = ThisWorkbook
wb.Activate
Dim str1 As String
Dim ar() As String
n = Sheets("基本資料").Cells(1, 60).End(xlToLeft).Column - 5
If n <= 0 Then Exit Sub
ReDim ar(n)
For i = 1 To n
ar(i - 1) = Sheets("基本資料").Cells(1, i + 5)
Next
str1 = Sheets("基本資料").Cells(1, 1) & Sheets("基本資料").Cells(1, 2)
If MsgBox("要備份資料嗎?", vbYesNo + vbQuestion, "訊息視窗") = vbYes Then
Application.DisplayAlerts = False
For i = 1 To n
FileName1 = ThisWorkbook.Path & "\" & str1 & "學期(" & ar(i - 1) & ")出缺勤暨獎懲登錄.xls"
With ActiveWorkbook
ActiveWorkbook.SaveCopyAs FileName:=FileName1 '漂亮
End With
Next
Else
MsgBox "再見 !", vbOKOnly + vbInformation, "訊息視窗"
End If
Application.DisplayAlerts = True
End Sub