Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Getting an Invalid Qualifier Error on this code, have no idea why.

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 

This part shows up as the cause of the Error

MsgBox "totalamount = " & totalamount.Value

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

Totalamount is an integer - it is not an object. An object is something like a range (ie: sheets(1).Range("A1")). Objects have properties, such as the value property. In this case, all you need is

MsgBox "totalamount = " & totalamount

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...