Excel精英培训网

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

[已解决]请大侠帮忙修改下,让汇总的数据不以文本格式显示。

[复制链接]
发表于 2011-11-1 15:29 | 显示全部楼层 |阅读模式
请大侠帮忙修改下,让汇总的数据不以文本格式显示。
在U48单元格将退货金额进行求和

数据合并显示.htm.rar (24.75 KB, 下载次数: 35)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2011-11-1 17:08 | 显示全部楼层
把退货金额的所有数据格式改成数值型不就可以了吗?
回复

使用道具 举报

发表于 2011-11-1 17:50 | 显示全部楼层    本楼为最佳答案   
新增红色那句!
Sub 汇总()
    Dim Wk As Workbook, myPath$, MyName$, i&
    Dim Sht As Worksheet, col&, j&
    Application.ScreenUpdating = False
    Set Sht = ActiveSheet
    Range("m6:r47", "t6:y47").ClearContents
    myPath = ThisWorkbook.Path & "\退货数据DATA\"
    MyName = Dir(myPath & "*.xls"): i = 6: col = 13
    Do While MyName <> ""
        Set Wk = Workbooks.Open(myPath & "\" & MyName)
        arr = Wk.Sheets(1).Range("B3:G" & Wk.Sheets(1).Range("B65536").End(3).Row)
        j = 0
        Do
            j = j + 1
            If i > 47 Then
                col = col + 7: i = 6
                If col > 20 Then MsgBox "数据溢出无法显示汇总全部内容。": Exit Sub
            End If
            If j <= UBound(arr) Then
                Sht.Cells(i, col).Resize(1, 6) = Application.Index(arr, j, 0): i = i + 1
                Sht.Cells(i, col).Offset(-1, 5) = Format(Sht.Cells(i, col).Offset(-1, 5), "0.00")            
Else
                Exit Do
            End If
        Loop While col < 21
        Wk.Close False
        MyName = Dir
    Loop
    Columns("q:q").NumberFormatLocal = "#,##0.00"
    Columns("x:x").NumberFormatLocal = "#,##0.00"
    Columns("r:r").NumberFormatLocal = "¥#,##0.00"
    Columns("y:y").NumberFormatLocal = "¥#,##0.00"
    Application.ScreenUpdating = True
    MsgBox "汇总完毕"
End Sub
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-15 01:32 , Processed in 0.240080 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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