Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1780|回复: 1

帮忙写汇总代码

[复制链接]
发表于 2019-10-13 11:19 | 显示全部楼层 |阅读模式
各位大侠:
   由于核算工资的数据太多,请帮忙在工作表“汇总“的按钮上写上代码,万分感谢!

34.rar

38.67 KB, 下载次数: 7

发表于 2019-10-13 21:54 | 显示全部楼层
If [a100000].End(3).Row > 1 Then
   Range(Cells(2, 1), Cells([a100000].End(3).Row, 6)).ClearContents
End If
hs = 2
For i = 1 To Worksheets.Count
    If Worksheets(i).Name <> "汇总" Then
       For j = 3 To Worksheets(i).[a100000].End(3).Row
           For k = 4 To Worksheets(i).[a2].End(2).Column
               If Not IsEmpty(Worksheets(1).Cells(j, k)) Then
                  s1 = Worksheets(i).Cells(j, 1)
                  s2 = Worksheets(i).Cells(2, k)
                  s3 = Worksheets(i).Cells(j, 2)
                  s4 = Worksheets(i).Cells(j, k)
                  s5 = Worksheets(i).Cells(j, 3)
                  s6 = s4 * s5
                  Cells(hs, 1) = s1
                  Cells(hs, 2) = s2
                  Cells(hs, 3) = s3
                  Cells(hs, 4) = s4
                  Cells(hs, 5) = s5
                  Cells(hs, 6) = s6
                  hs = hs + 1
               End If
            Next k
       Next j
    End If
Next i
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-19 22:37 , Processed in 0.257157 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表