|
- Sub test()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim i%, p$, maxRow%, totalRow%, wb As Workbook, ws As Worksheet, tws As Worksheet
- Dim wc%, qj%, yj%, kg%, wj%
- p = "0"
- totalRow = 2
- Set tws = Sheet1
- For i = 1 To 11
- If i >= 10 Then p = ""
- Set wb = GetObject(ThisWorkbook.Path & "\201810" & p & i & "-5.xls")
- Set ws = wb.Sheets(1)
- maxRow = ws.[A1].End(xlDown).Row
- ws.Range("A2", "D" & maxRow).Copy tws.Range("A" & totalRow)
- If Not ws.Rows(1).Find("完成") Is Nothing Then
- wc = ws.Rows(1).Find("完成").Column
- ws.Range(ws.Cells(2, wc), ws.Cells(maxRow, wc)).Copy tws.Range("E" & totalRow)
- End If
- If Not ws.Rows(1).Find("请假") Is Nothing Then
- qj = ws.Rows(1).Find("请假").Column
- ws.Range(ws.Cells(2, qj), ws.Cells(maxRow, qj)).Copy tws.Range("F" & totalRow)
- End If
- If Not ws.Rows(1).Find("业绩") Is Nothing Then
- yj = ws.Rows(1).Find("业绩").Column
- ws.Range(ws.Cells(2, yj), ws.Cells(maxRow, yj)).Copy tws.Range("G" & totalRow)
- End If
- If Not ws.Rows(1).Find("旷工") Is Nothing Then
- kg = ws.Rows(1).Find("旷工").Column
- ws.Range(ws.Cells(2, kg), ws.Cells(maxRow, kg)).Copy tws.Range("H" & totalRow)
- End If
- If Not ws.Rows(1).Find("违纪") Is Nothing Then
- wj = ws.Rows(1).Find("违纪").Column
- ws.Range(ws.Cells(2, wj), ws.Cells(maxRow, wj)).Copy tws.Range("I" & totalRow)
- End If
- wb.Close False
- totalRow = totalRow + maxRow - 1
- Next
- End Sub
复制代码
没用字典,纯复制 |
|