Excel VBA:运行时错误438

时间:2016-05-09 05:27:35

标签: vba excel-vba ms-office excel

我尝试制作一个按钮并为其指定一个宏。 当我点击按钮运行宏时,它说:

  

运行时错误438:对象不支持此属性或方法

以下代码行被标记:

With Sheets("1. Stock & Demand")
    .Range("F3:F3").End(xlToRight).Offset(-2, 1).Paste
End With

以下是完整的代码:

Sub NeuerTag()

'Abfrage ob der Tag eingefügt werden soll, No = QUIT'
If MsgBox("Möchtest du die Tabelle vorbereiten?", vbYesNo) = vbNo Then Exit Sub

'Copies the last three coloumns of the Worksheet 1. Stock & Demand'
With Sheets("1. Stock & Demand")
Lastcol = .Cells(1, .Columns.Count).End(xlToLeft).Column
.Columns(Lastcol - 1).Resize(, 1).Copy
End With

'Selects the first empty cell in 1. Stock & Demand and pastes'
With Sheets("1. Stock & Demand")
.Range("F3:F3").End(xlToRight).Offset(-2, 1).Paste
End With

'Pastes the Today()'
With Sheets("1. Stock & Demand")
.Range("F3:ZZ3").End(xlToRight).Offset(-1, 0).Value = Date
End With

'Paste Special - Values'
With Sheets("1. Stock & Demand")
Lastcol = .Cells(1, .Columns.Count).End(xlToLeft).Column
.Columns(Lastcol - 3).Resize(, 1).PasteSpecial Paste:=xlPasteValues
End With

End Sub

1 个答案:

答案 0 :(得分:0)

我认为.offset没有.paste方法,所以请尝试使用.pasteSpecial