|
仅供参考
- Sub test()
- Dim a%, n%, i%, sr As Long, s As Worksheet, sh As Worksheet
- Set s = Sheets("计算")
- a = 1
- For Each sh In Sheets
- If sh.Name <> "计算" Then
- n = n + 1
- s.Cells(1, a) = "CX" & n '第一列CXn编碼
- With s.Range(s.Cells(1, a), s.Cells(1, a + 2)) '合併第一列3栏並置中
- .Merge
- .HorizontalAlignment = xlCenter
- End With
- For sr = 2 To sh.[A65536].End(xlUp).Row
- For i = a To a + 2 '一次计算三行
- If i = a Then
- s.Cells(sr, i) = sh.Cells(sr, 13) - sh.Cells(sr, 6) 'M-F
- ElseIf i = a + 1 Then
- s.Cells(sr, i) = sh.Cells(sr, 20) - sh.Cells(sr, 13) 'T-M
- ElseIf i = a + 2 Then
- s.Cells(sr, i) = sh.Cells(sr, 20) - sh.Cells(sr, 6) 'T-F
- End If
- Next i
- Next sr
- a = i
- End If
- Next sh
- End Sub
复制代码 |
|