我正在做一个工厂数据收集作业/项目(我是一名实习生)。我的宏的早期版本使用表单命令按钮,它可以很好地工作(正确收集了数据)
现在,我将表单按钮更改为ActiveX(以便可以将图像用作按钮)。但是,它报告“运行时错误1004-Range类的选择方法失败”。该错误就在Rows(“ 5:5”)开头。选择
Sub TransferButton_Click()
Sheets("VIE Screen").Select
If Range("D23").Value = "OK" Then
Sheets("Crusher tracking").Select
Rows("5:5").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows("6:6").Select
Selection.Copy
Rows("5:5").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("r4").Select
Selection.Copy
Range("r5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("s4").Select
Selection.Copy
Range("s4").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("VIE Screen").Select
'The origin of the input-ed data
Range("M9:AO9").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Crusher tracking").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("VIE Screen").Select
'This is for "refreshing" the input page, creating a blank form for future input
Range("C7").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("E7:H7").Select
Selection.ClearContents
Range("B11:H11").Select
Selection.ClearContents
Range("B16:H16").Select
Selection.ClearContents
Range("D17:H17").Select
Selection.ClearContents
Range("D18:H18").Select
Selection.ClearContents
End If
End Sub