VBA學習第四課
阿新 • • 發佈:2018-11-29
Sub ss() Dim biao As Worksheet Excel.Application.DisplayAlerts = False For Each biao In Sheets If biao.Name <> "絕不能刪" Then biao.Delete End If Next Excel.Application.DisplayAlerts = True End Sub
Sub xinjian() Dim sht As Worksheet For Each sht In Sheets sht.Copy ActiveWorkbook.SaveAs Filename:="d:\data\" & sht.Name & "" ActiveWorkbook.Close Next End Sub
Sub test() Dim i As Integer Dim sht As Worksheet For Each sht In Worksheets sht.Select For i = 100 To 2 Step -1 '處理性別的程式碼 If Range("e" & i) = "男" Then Range("f" & i) = "先生" Else Range("f" & i) = "女士" End If '處理專業代號 If Range("b" & i) = "理工" Then Range("c" & i) = "LG" ElseIf Range("b" & i) = "文科" Then Range("c" & i) = "WK" Else Range("c" & i) = "CJ" End If '刪除空行 If Range("d" & i) = "" Then Range("D" & i).Select Selection.EntireRow.Delete End If Next '拆分表 sht.Copy ActiveWorkbook.SaveAs Filename:="d:\data\" & sht.Name & ".xlsx" ActiveWorkbook.Close Next End Sub