Excel VBA“;无效限定符错误“;

Excel VBA“;无效限定符错误“;,excel,vba,Excel,Vba,获取此代码的无效限定符错误,不知道原因 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 R

获取此代码的无效限定符错误,不知道原因

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.Value
中删除
.Value

totalAmount
是基元类型的变量,基元变量没有方法

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

Totalamount是一个整数-它不是一个对象。对象类似于一个范围(即:sheets(1).range(“A1”))。对象具有属性,例如值属性。在这种情况下,您只需要

MsgBox "totalamount = " & totalamount
它是
MsgBox“totalamount=“&totalamount
仅不带
。value