ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1026|回复: 1

宏高手请进,请帮忙!

[复制链接]

TA的精华主题

TA的得分主题

发表于 2014-4-21 12:12 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
请高手帮忙看看,为什么出现错误,感谢!


Sub Macro1()
'
' Macro1 Macro
' 宏由  录制,时间: 2014-4-19
'
' 快捷键: Ctrl+b
'
    Windows("1111111111111.XLS").Activate
    Cells.Select
    Selection.Copy
    Windows("测试.xls").Activate
    ActiveSheet.Paste
    Columns("A:A").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:H").Select
    Selection.Delete Shift:=xlToLeft
    Columns("G:AC").Select
    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlToLeft
    Range("B2:B64").Select
    ActiveWindow.SmallScroll Down:=-60
    Range("B2:B192").Select
    ActiveWindow.SmallScroll Down:=-195
    Range("F2:F1214").Select
    ActiveWindow.LargeScroll Down:=-1
    ActiveWindow.ScrollRow = 1151
    ActiveWindow.ScrollRow = 1145
    ActiveWindow.ScrollRow = 1135
    ActiveWindow.ScrollRow = 1122
    ActiveWindow.ScrollRow = 1108
    ActiveWindow.ScrollRow = 1096
    ActiveWindow.ScrollRow = 1086
    ActiveWindow.ScrollRow = 1075
    ActiveWindow.ScrollRow = 1063
    ActiveWindow.ScrollRow = 1049
    ActiveWindow.ScrollRow = 1037
    ActiveWindow.ScrollRow = 1028
    ActiveWindow.ScrollRow = 1020
    ActiveWindow.ScrollRow = 1012
    ActiveWindow.ScrollRow = 1002
    ActiveWindow.ScrollRow = 994
    ActiveWindow.ScrollRow = 977
    ActiveWindow.ScrollRow = 963
    ActiveWindow.ScrollRow = 955
    ActiveWindow.ScrollRow = 928
    ActiveWindow.ScrollRow = 892
    ActiveWindow.ScrollRow = 847
    ActiveWindow.ScrollRow = 798
    ActiveWindow.ScrollRow = 755
    ActiveWindow.ScrollRow = 716
    ActiveWindow.ScrollRow = 695
    ActiveWindow.ScrollRow = 675
    ActiveWindow.ScrollRow = 655
    ActiveWindow.ScrollRow = 632
    ActiveWindow.ScrollRow = 593
    ActiveWindow.ScrollRow = 571
    ActiveWindow.ScrollRow = 555
    ActiveWindow.ScrollRow = 518
    ActiveWindow.ScrollRow = 501
    ActiveWindow.ScrollRow = 483
    ActiveWindow.ScrollRow = 465
    ActiveWindow.ScrollRow = 444
    ActiveWindow.ScrollRow = 428
    ActiveWindow.ScrollRow = 407
    ActiveWindow.ScrollRow = 379
    ActiveWindow.ScrollRow = 367
    ActiveWindow.ScrollRow = 356
    ActiveWindow.ScrollRow = 344
    ActiveWindow.ScrollRow = 342
    ActiveWindow.ScrollRow = 332
    ActiveWindow.ScrollRow = 318
    ActiveWindow.ScrollRow = 299
    ActiveWindow.ScrollRow = 283
    ActiveWindow.ScrollRow = 269
    ActiveWindow.ScrollRow = 258
    ActiveWindow.ScrollRow = 246
    ActiveWindow.ScrollRow = 224
    ActiveWindow.ScrollRow = 213
    ActiveWindow.ScrollRow = 203
    ActiveWindow.ScrollRow = 179
    ActiveWindow.ScrollRow = 158
    ActiveWindow.ScrollRow = 144
    ActiveWindow.ScrollRow = 130
    ActiveWindow.ScrollRow = 117
    ActiveWindow.ScrollRow = 109
    ActiveWindow.ScrollRow = 101
    ActiveWindow.ScrollRow = 91
    ActiveWindow.ScrollRow = 85
    ActiveWindow.ScrollRow = 72
    ActiveWindow.ScrollRow = 58
    ActiveWindow.ScrollRow = 44
    ActiveWindow.ScrollRow = 32
    ActiveWindow.ScrollRow = 23
    ActiveWindow.ScrollRow = 13
    ActiveWindow.ScrollRow = 11
    ActiveWindow.ScrollRow = 9
    ActiveWindow.ScrollRow = 5
    ActiveWindow.ScrollRow = 1
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("A:H").Select
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!C1:C5").CreatePivotTable TableDestination:="", TableName:="数据透视表1" _
        , DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("仓库名称")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("存货编码")
        .Orientation = xlRowField
        .Position = 2
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("存货名称")
        .Orientation = xlRowField
        .Position = 3
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("批号")
        .Orientation = xlRowField
        .Position = 4
    End With
    ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _
        ).PivotFields("现存数量"), "计数项:现存数量", xlCount
    Range("E9").Select
    ActiveSheet.PivotTables("数据透视表1").PivotFields("计数项:现存数量").Function = xlSum
    Cells.Select
    Selection.Copy
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Selection.Copy
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Rows("1:3").Select
    Range("A3").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    Range("A3").Select
    ActiveWindow.SmallScroll Down:=-36
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-4-21 13:00 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-28 22:04 , Processed in 0.043816 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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