ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

代码运行出错,求解!

[复制链接]

TA的精华主题

TA的得分主题

发表于 2012-11-6 18:05 | 显示全部楼层 |阅读模式
本帖最后由 霞竹之景 于 2012-11-6 18:07 编辑

我在录制宏后运行代码实,跳出如下对话框,不知如何解决,请各位老师指点一二(下面有原代码)。谢谢!


image002.jpg


Sub 订单粉末用量计算()
'
' 订单粉末用量计算 Macro
'

'
   Rows("1:1").Select
   Selection.AutoFilter
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.AddKey:=Range _
       ("E1"), SortOn:=xlSortOnValues, Order:=xlAscending,DataOption:= _
       xlSortNormal
   With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
       .Header = xlYes
       .MatchCase = False
       .Orientation = xlTopToBottom
       .SortMethod = xlPinYin
       .Apply
   End With
   Columns("I:I").Select
   Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
   Range("I1").Select
   ActiveCell.FormulaR1C1 = "单面积"
   With ActiveCell.Characters(Start:=1, Length:=3).Font
       .Name = "宋体"
       .FontStyle = "常规"
       .Size = 9
       .Strikethrough = False
       .Superscript = False
       .Subscript = False
       .OutlineFont = False
       .Shadow = False
       .Underline = xlUnderlineStyleNone
       .ColorIndex = xlAutomatic
       .TintAndShade = 0
       .ThemeFont = xlThemeFontNone
   End With
   Columns("J:J").Select
   Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
   Range("J1").Select
   ActiveCell.FormulaR1C1 = "总面积"
   Range("I2").Select
   ActiveCell.FormulaR1C1 = _
       "=VLOOKUP(RC[-8],[2012.09.11价格总表.xls]Sheet1!R2C3:R5100C24,21,0)"
   Range("J2").Select
   ActiveCell.FormulaR1C1 = "=RC[-4]*RC[-1]"
   Range("I2:J2").Select
   Selection.AutoFill Destination:=Range("I2:J200"),Type:=xlFillDefault
   Range("I2:J200").Select
   ActiveWindow.SmallScroll Down:=-90
   ActiveWindow.ScrollRow = 104
   ActiveWindow.ScrollRow = 102
   ActiveWindow.ScrollRow = 101
   ActiveWindow.ScrollRow = 98
    ActiveWindow.ScrollRow= 95
   ActiveWindow.ScrollRow = 89
   ActiveWindow.ScrollRow = 85
   ActiveWindow.ScrollRow = 79
   ActiveWindow.ScrollRow = 73
   ActiveWindow.ScrollRow = 68
   ActiveWindow.ScrollRow = 59
   ActiveWindow.ScrollRow = 56
    ActiveWindow.ScrollRow= 52
   ActiveWindow.ScrollRow = 49
   ActiveWindow.ScrollRow = 46
   ActiveWindow.ScrollRow = 43
   ActiveWindow.ScrollRow = 42
   ActiveWindow.ScrollRow = 39
   ActiveWindow.ScrollRow = 36
   ActiveWindow.ScrollRow = 31
    ActiveWindow.ScrollRow= 27
   ActiveWindow.ScrollRow = 26
   ActiveWindow.ScrollRow = 21
   ActiveWindow.ScrollRow = 18
   ActiveWindow.ScrollRow = 14
   ActiveWindow.ScrollRow = 10
   ActiveWindow.ScrollRow = 7
   ActiveWindow.ScrollRow = 1
   ActiveWindow.ScrollRow = 2
   ActiveWindow.ScrollRow = 4
   ActiveWindow.ScrollRow = 5
   ActiveWindow.ScrollRow = 8
   ActiveWindow.ScrollRow = 10
   ActiveWindow.ScrollRow = 11
   ActiveWindow.ScrollRow = 13
   ActiveWindow.ScrollRow = 14
    ActiveWindow.ScrollRow= 15
   ActiveWindow.ScrollRow = 17
   ActiveWindow.ScrollRow = 18
   ActiveWindow.ScrollRow = 20
   ActiveWindow.ScrollRow = 21
   ActiveWindow.ScrollRow = 23
   ActiveWindow.ScrollRow = 24
   ActiveWindow.ScrollRow = 26
    ActiveWindow.ScrollRow= 27
   ActiveWindow.ScrollRow = 29
   ActiveWindow.ScrollRow = 27
   ActiveWindow.ScrollRow = 26
   ActiveWindow.ScrollRow = 24
   ActiveWindow.ScrollRow = 21
   ActiveWindow.ScrollRow = 18
   ActiveWindow.ScrollRow = 17
    ActiveWindow.ScrollRow= 15
   ActiveWindow.ScrollRow = 13
   ActiveWindow.ScrollRow = 11
   ActiveWindow.ScrollRow = 10
   ActiveWindow.ScrollRow = 7
   ActiveWindow.ScrollRow = 5
   ActiveWindow.ScrollRow = 2
   ActiveWindow.ScrollRow = 1
   ActiveWindow.SmallScroll ToRight:=6
   Range("P1").Select
   ActiveCell.FormulaR1C1 = "塑粉名称"
   With ActiveCell.Characters(Start:=1, Length:=4).Font
       .Name = "宋体"
       .FontStyle = "常规"
       .Size = 10
       .Strikethrough = False
       .Superscript = False
       .Subscript = False
       .OutlineFont = False
       .Shadow = False
       .Underline = xlUnderlineStyleNone
       .ColorIndex = xlAutomatic
       .TintAndShade = 0
       .ThemeFont = xlThemeFontNone
   End With
   Range("Q1").Select
   ActiveCell.FormulaR1C1 = "塑粉用量"
   With ActiveCell.Characters(Start:=1, Length:=4).Font
       .Name = "宋体"
       .FontStyle = "常规"
       .Size = 10
       .Strikethrough = False
       .Superscript = False
       .Subscript = False
       .OutlineFont = False
       .Shadow = False
       .Underline = xlUnderlineStyleNone
       .ColorIndex = xlAutomatic
       .TintAndShade = 0
       .ThemeFont = xlThemeFontNone
   End With
   Range("Q2").Select
   ActiveCell.FormulaR1C1 = "=SUMIF(C[-12],RC[-1],C[-7])/5.32"
   Range("Q2").Select
   Selection.AutoFill Destination:=Range("Q2:Q11"),Type:=xlFillDefault
   Range("Q2:Q11").Select
   Columns("Q:Q").Select
   Selection.NumberFormatLocal = "0.00_);[红色](0.00)"
   ActiveWindow.SmallScroll Down:=-6
End Sub

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

本版积分规则

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

GMT+8, 2024-11-27 09:54 , Processed in 0.038356 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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