在此代码上获得无效的限定符错误,不知道为什么。

Dim WTotal As Integer
WTotal = InputBox("Enter the amount of Wash")
Dim Startpoint As Range
Dim totalamount As Integer

Sheets("Sheet2").Select
Set Startpoint = ActiveSheet.Cells.Find(What:="Wash")
Startpoint.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
totalamount = Selection.Count

MsgBox "totalamount = " & totalamount.Value


这部分显示为错误的原因

MsgBox“ totalamount =”&totalamount.Value

最佳答案

Totalamount是一个整数-它不是对象。一个对象就像一个范围(例如sheets(1).Range(“ A1”))。对象具有属性,例如value属性。在这种情况下,您所需要做的就是

MsgBox "totalamount = " & totalamount

10-01 03:01