|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这里假定引用的总表名称为100,200,300,400四个总表,1-20个分表1-5引用总表100,6-10引用总表200,,1-15引用总表300,16-20引用总表400,编写代码如下
Sub test()
Dim k1%, k2%, k3%, k4%, j$
For Each sht In Worksheets
j = sht.Name
i = j + 0
Select Case i
Case Is < 6
sht.Cells(2, 2) = Worksheets("100").Cells(k1 + 1, 4)
k1 = k1 + 1
Case Is < 11
sht.Cells(2, 2) = Worksheets("200").Cells(k2 + 1, 4)
k2 = k2 + 1
Case Is < 16
sht.Cells(2, 2) = Worksheets("300").Cells(k3 + 1, 4)
k3 = k3 + 1
Case Is < 21
sht.Cells(2, 2) = Worksheets("400").Cells(k4 + 1, 4)
k4 = k4 + 1
End Select
Next
End Sub |
|