>即時新聞-熱門

2009年6月29日星期一

excel vba

Sub 插入工作表()

Sheets(1).Select
Sheets.Add
Sheets(1).Select
End Sub
Sub 單位清單()

With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="衛生,人事,總務,行政,財務,其他"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End Sub
Sub 合併工作表()
插入工作表
x = InputBox("請輸入合併工作表的數量")
Sheets(2).Select
xa = "1:" & x
Range(xa).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets(1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
For i = 3 To x + 1
Sheets(i).Select
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets(1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Next
Range("A1").Select

End Sub

0 评论:

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱