|
Sub 宏1()
Dim sht As Worksheet
Application.DisplayAlerts = False
For Each sht In Worksheets
If sht.Name <> "计算" Then
sht.Delete
End If
Next
Application.DisplayAlerts = True
For i = 2023 To 2024
For j = 1 To 12
Set sht = Sheets.Add(After:=Sheets(Sheets.Count))
sht.Name = i & Format(j, "00")
sht.Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=Excel Files;DBQ=" & ThisWorkbook.FullName & ";DefaultDir=C:\Users\Administrator\" _
), Array( _
"Desktop\按要求拆分汇总工作表生成新的工作表;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;")), _
Destination:=Range("$A$1")).QueryTable
.CommandText = "SELECT 个人编号,性别,档案出生日期,个人身份,退休类别,法定退休年龄,应退年度,应退月份 FROM [计算$] where 应退年度=" & i & " and 应退月份=" & j
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "表_" & i & Format(j, "00")
.Refresh BackgroundQuery:=False
End With
Next j
Next i
End Sub
|
评分
-
1
查看全部评分
-
|