excel宏模块1与模块2合并的问题
用宏录制了一些命令,分模块1(内有宏1~宏4),模块2(内有宏5)。现在要把模块2里的命令合并到模块1里,我到VBA编辑器里复制模块2里的宏5命令行,合并粘贴在模块1后面...
用宏录制了一些命令,分模块1(内有宏1~宏4),模块2(内有宏5)。
现在要把模块2里的命令合并到模块1里,我到VBA编辑器里复制模块2里的宏5命令行,合并粘贴在模块1后面。
但重启加载模块1后,这复制的宏5失效,请问是什么问题?如何解决?
Sub 宏5()
'
' 宏5 宏
' 选中序号,按Ctrl+t删除表头
'
' 快捷键: Ctrl+t
'
ActiveWindow.SmallScroll Down:=267
Range("A3:K300").Select
ActiveWindow.ScrollRow = 283
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Selection.AutoFilter
ActiveSheet.Range("$A$3:$K$103").AutoFilter Field:=1, Criteria1:="="
Rows("12:12").Select
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 48
ActiveWindow.ScrollRow = 50
ActiveWindow.ScrollRow = 51
ActiveWindow.ScrollRow = 101
ActiveWindow.ScrollRow = 102
ActiveWindow.ScrollRow = 103
ActiveWindow.SmallScroll Down:=183
Rows("6:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-24
ActiveSheet.Range("$A$3:$K$57").AutoFilter Field:=1
Range("C3:C5").Select
ActiveSheet.Range("$A$3:$K$57").AutoFilter Field:=3, Criteria1:="="
Rows("11:11").Select
ActiveWindow.SmallScroll Down:=258
Rows("11:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-9
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=3
ActiveWindow.SmallScroll Down:=-15
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6, Criteria1:="="
Rows("35:35").Select
ActiveWindow.SmallScroll Down:=264
Rows("35:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-42
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6
ActiveWindow.SmallScroll Down:=-15
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=7, Criteria1:="="
ActiveWindow.SmallScroll Down:=-21
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=7
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6, Criteria1:="工程量"
ActiveWindow.SmallScroll Down:=-21
Rows("11:11").Select
ActiveWindow.SmallScroll Down:=264
Rows("11:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-24
ActiveSheet.Range("$A$3:$K$29").AutoFilter Field:=6
Range("F6").Select
ActiveWindow.SmallScroll Down:=-21
Range("A3:A5").Select
End Sub
代码过长无法贴上了,删去了一些类似命令 展开
现在要把模块2里的命令合并到模块1里,我到VBA编辑器里复制模块2里的宏5命令行,合并粘贴在模块1后面。
但重启加载模块1后,这复制的宏5失效,请问是什么问题?如何解决?
Sub 宏5()
'
' 宏5 宏
' 选中序号,按Ctrl+t删除表头
'
' 快捷键: Ctrl+t
'
ActiveWindow.SmallScroll Down:=267
Range("A3:K300").Select
ActiveWindow.ScrollRow = 283
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Selection.AutoFilter
ActiveSheet.Range("$A$3:$K$103").AutoFilter Field:=1, Criteria1:="="
Rows("12:12").Select
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 48
ActiveWindow.ScrollRow = 50
ActiveWindow.ScrollRow = 51
ActiveWindow.ScrollRow = 101
ActiveWindow.ScrollRow = 102
ActiveWindow.ScrollRow = 103
ActiveWindow.SmallScroll Down:=183
Rows("6:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-24
ActiveSheet.Range("$A$3:$K$57").AutoFilter Field:=1
Range("C3:C5").Select
ActiveSheet.Range("$A$3:$K$57").AutoFilter Field:=3, Criteria1:="="
Rows("11:11").Select
ActiveWindow.SmallScroll Down:=258
Rows("11:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-9
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=3
ActiveWindow.SmallScroll Down:=-15
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6, Criteria1:="="
Rows("35:35").Select
ActiveWindow.SmallScroll Down:=264
Rows("35:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-42
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6
ActiveWindow.SmallScroll Down:=-15
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=7, Criteria1:="="
ActiveWindow.SmallScroll Down:=-21
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=7
ActiveSheet.Range("$A$3:$K$34").AutoFilter Field:=6, Criteria1:="工程量"
ActiveWindow.SmallScroll Down:=-21
Rows("11:11").Select
ActiveWindow.SmallScroll Down:=264
Rows("11:300").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-24
ActiveSheet.Range("$A$3:$K$29").AutoFilter Field:=6
Range("F6").Select
ActiveWindow.SmallScroll Down:=-21
Range("A3:A5").Select
End Sub
代码过长无法贴上了,删去了一些类似命令 展开
2个回答
展开全部
录制的宏可以复制过去,不会有问题,如果你出现失效,一般不会是复制代码造成的,而是代码的环境发生了变化,例如依赖的工作表名字改变等。
如需进一步分许,请粘贴代码。
如需进一步分许,请粘贴代码。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询