我最近编码的VBA出现问题,我也不知道为什么会出现错误。 问题是,当我运行代码时,它工作得很好。当我的一位同事运行该代码时,它也很好。但是有一些老同事,当他们尝试运行代码时,会出现上述错误消息。
您认为它的出现是因为它们的设备较旧,还是您会提出什么建议? 这是代码:
Sub Datenauswerten()
Application.ScreenUpdating = False
Sheets("Auswertung").Visible = True
Sheets("Auswertung").Select
Range("A1:D100").Select
Selection.ClearContents
Sheets("Pivot").Select
Range("B6").Select
ActiveWorkbook.RefreshAll
Range("D7").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Sheets("Auswertung").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Auswertung").Range("b1").Value = "Kategorie"
Sheets("Auswertung").Range("c1").Value = "Störung"
Sheets("Auswertung").Range("d1").Value = "Dauer [h]"
Cells.Select
Cells.EntireColumn.AutoFit
Range("D1").Select
ActiveWorkbook.Worksheets("Auswertung").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Auswertung").Sort.SortFields.Add
Key:=Range("D1"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Auswertung").Sort
.SetRange Range("A2:D100")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A5:D100").Select
Selection.ClearContents
Range("A:A").Select
Selection.ClearContents
Columns("D:D").Select
Selection.NumberFormat = "0.00"
Sheets("Auswertung").Range("b1").Value = "Kategorie"
Sheets("Auswertung").Range("c1").Value = "Störung"
Sheets("Auswertung").Range("d1").Value = "Dauer [h]"
Sheets("Auswertung").Range("A1").Select
Sheets("Grafik").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).Values = "=Auswertung!$D$2:$D$4"
ActiveChart.FullSeriesCollection(1).XValues = "=Auswertung!$B$2:$C$4"
Sheets("Auswertung").Select
Range("A50").Select
Sheets("Auswertung").Visible = False
Application.ScreenUpdating = True
End Sub
非常感谢您的帮助!