Excel精英培训网

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

[已解决]请教如何实现图片上的效果,恳请大师帮忙!

[复制链接]
发表于 2011-11-1 09:23 | 显示全部楼层 |阅读模式
2011-11-01_092036.jpg


数据合并显示.rar (16.87 KB, 下载次数: 19)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2011-11-1 10:45 | 显示全部楼层
  1. Sub 汇总()
  2.     Dim Wk As Workbook, myPath$, MyName$, i&
  3.     Dim Sht As Worksheet, col&, j&
  4.     Application.ScreenUpdating = False
  5.     Set Sht = ActiveSheet
  6.     Range("m6:r47", "t6:y47").ClearContents
  7.     myPath = ThisWorkbook.Path & "\退货数据DATA"
  8.     MyName = Dir(myPath & "*.xls"): i = 6: col = 13
  9.     Do While MyName <> ""
  10.         Set Wk = Workbooks.Open(myPath & "" & MyName)
  11.         arr = Wk.Sheets(1).Range("B3:G" & Wk.Sheets(1).Range("B65536").End(3).Row)
  12.         j = 0
  13.         Do
  14.             j = j + 1
  15.             If i > 47 Then
  16.                 col = col + 7: i = 6
  17.                 If col > 20 Then MsgBox "数据溢出无法显示汇总全部内容。": Exit Sub
  18.             End If
  19.             If j <= UBound(arr) Then
  20.                 Sht.Cells(i, col).Resize(1, 6) = Application.Index(arr, j, 0): i = i + 1
  21.             Else
  22.                 Exit Do
  23.             End If
  24.         Loop While col < 21
  25.         Wk.Close False
  26.         MyName = Dir
  27.     Loop
  28.     Columns("q:q").NumberFormatLocal = "#,##0.00"
  29.     Columns("x:x").NumberFormatLocal = "#,##0.00"
  30.     Columns("r:r").NumberFormatLocal = "¥#,##0.00"
  31.     Columns("y:y").NumberFormatLocal = "¥#,##0.00"
  32.     Application.ScreenUpdating = True
  33.     MsgBox "汇总完毕"
  34. End Sub

复制代码
回复

使用道具 举报

发表于 2011-11-1 10:47 | 显示全部楼层    本楼为最佳答案   
请见附件。

数据合并显示.rar

15.58 KB, 下载次数: 29

回复

使用道具 举报

 楼主| 发表于 2011-11-1 11:09 | 显示全部楼层
回复 蓝桥玄霜 的帖子

老师能否帮忙把Q、R、X、Y汇总后显示的数值改成 数字格式,文本格式无法使用SUM求和
回复

使用道具 举报

发表于 2011-11-3 10:05 | 显示全部楼层
把后面两句删除即可。
    'Columns("r:r").NumberFormatLocal = "¥#,##0.00"
    'Columns("y:y").NumberFormatLocal = "¥#,##0.00"
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-20 05:34 , Processed in 0.238404 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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