Excel精英培训网

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

[已解决]怎么样汇总工作表的合计数

[复制链接]
发表于 2017-8-21 18:37 | 显示全部楼层 |阅读模式
按照sheet名称确定部门,汇总各sheet合计这一行的销售额、销售奖励及合计数
最佳答案
2017-8-21 18:54
  1. Sub t()
  2. Dim i As Integer
  3. Range("A2:E65536").ClearContents
  4. For i = 1 To Sheets.Count
  5.     If Sheets(i).Name <> "汇总" Then
  6.         With Sheets(i)
  7.         Cells(65536, 2).End(xlUp).Offset(1) = Left(Sheets(i).Name, Len(Sheets(i).Name) - 2)
  8.         Cells(65536, 3).End(xlUp).Offset(1) = .Cells(65536, 5).End(xlUp)
  9.         Cells(65536, 4).End(xlUp).Offset(1) = .Cells(65536, 6).End(xlUp)
  10.         Cells(65536, 5).End(xlUp).Offset(1) = .Cells(65536, 7).End(xlUp)
  11.         End With
  12.     End If


  13. Next
  14. End Sub
复制代码
 楼主| 发表于 2017-8-21 18:39 | 显示全部楼层
补充图片及文件

图片

图片

6月份销售业绩2.rar

12.6 KB, 下载次数: 13

示例

回复

使用道具 举报

发表于 2017-8-21 18:54 | 显示全部楼层    本楼为最佳答案   
  1. Sub t()
  2. Dim i As Integer
  3. Range("A2:E65536").ClearContents
  4. For i = 1 To Sheets.Count
  5.     If Sheets(i).Name <> "汇总" Then
  6.         With Sheets(i)
  7.         Cells(65536, 2).End(xlUp).Offset(1) = Left(Sheets(i).Name, Len(Sheets(i).Name) - 2)
  8.         Cells(65536, 3).End(xlUp).Offset(1) = .Cells(65536, 5).End(xlUp)
  9.         Cells(65536, 4).End(xlUp).Offset(1) = .Cells(65536, 6).End(xlUp)
  10.         Cells(65536, 5).End(xlUp).Offset(1) = .Cells(65536, 7).End(xlUp)
  11.         End With
  12.     End If


  13. Next
  14. End Sub
复制代码
回复

使用道具 举报

发表于 2017-8-21 22:57 | 显示全部楼层
6月份销售业绩2.rar (14.97 KB, 下载次数: 14)
回复

使用道具 举报

 楼主| 发表于 2017-8-22 09:09 | 显示全部楼层
感谢,代码测试可用
回复

使用道具 举报

 楼主| 发表于 2017-8-22 09:12 | 显示全部楼层

谢谢回复,这个函数也很厉害哦,但是因为3楼大哥回复的比较早,而且部门也是直接生成的,所以最佳答案我还是选了他,不过你的函数思路也很值得我学习,再次感谢
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 23:38 , Processed in 0.316125 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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