|
楼主 |
发表于 2011-9-7 11:32
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
谢谢!!
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
麻烦帮我看看,怎么运行到后出现“类型不匹配”???
|
|