作者:乔山办公网日期:
返回目录:excel表格制作
下面的代码是导百入指定工作薄的度所有工作表
Sub 导入()
drfile = InputBox("请输入要导入的专excel文件名属(不包含扩展名):", "输入")
drfile = drfile & ".xls"
Workbooks.Open ThisWorkbook.Path & "\" & drfile
drcount = Workbooks(drfile).Sheets.Count
For i = 1 To drcount
With Workbooks(drfile)
.Sheets(i).Copy after:=ThisWorkbook.Sheets(Sheets.Count)
End With
Next
Workbooks(drfile).Close False
End Sub
加上一句e799bee5baa6e79fa5e98193e59b9ee7ad94364代码:
Range("c3:g15000").NumberFormat = "000"
Private Sub CommandButton1_Click()
Range("A3:I15000").Clear
k3dshijihao = "F:\CQ\shishicai.txt"
d3s = "WData3D_All"
cz = k3dshijihao: czmc = d3s
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & cz, Destination:=Range("A3"))
.Name = czmc
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = no
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 60
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 0, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A" & (Application.Count(Range("a1:a15000")))).Select
Range("c3:g15000").NumberFormat = "000"
End
End Sub
Private Sub SortRange()
Range("A3:G10002").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
首先百EXCEL必需有一个空白的工作表,度即除了sheet1,sheet2,sheet3外还有其它工作表,方可回把三个全删除
示例:
sub delSheet()
'导入我就不写了答
……
……
dim wb as workbook
set wb=ActiveWorkbook
'屏蔽对话框
Application.DisplayAlerts = False
wb.Worksheets("Sheet1").Delete
wb.Worksheets("Sheet2").Delete
wb.Worksheets("Sheet3").Delete
Application.DisplayAlerts = TRUE
end sub