To tell VBA that you only want the number 10, you can use the parameter LookAt:=XlWhole. LookAt indicates whether or not the value must be exactly equal to the value sought, or partially equal.įor example, if one were to search for the value "10" in a matrix including: 6210, 4105, 540, 163, 154, 132, 10, there are various methods you can use. Other variations of LookIn include xlValues, xlFormulas, and xlComments. The parameter is used to locate a value in a range. If After is not specified, the search will begin in the upper left corner of the range. This parameter indicates the starting cell for the search (note that the cell must be unique). It can be of any data type supported by Excel. This parameter allows you to stipulate which value you want to find in your range. MyRange: This expression represents the Range object, which designates in which cells you'd like to search for the value contained in What parameter.MyRange.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, SearchFormat) Here is a quick breakdown of all of the parameters of the Find method.
SearchFormat:=False).Activate How to understand the Find method?
Note that the search term used for this example is Value:Ĭells.Find(What:="Value", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, Here is how the Find function would look in VBA. How to search data using the Find method in VBA? Simply type in the keyword or value you're searching for and hit Enter.Įxcel will highlight all of the cells that correspond to your search. If you're looking to perform a simple search of all data in a workbook, you can do so by simply pressing the + F keys on your keyboard. The Find function works very similarly to a basic search function. Search data using the Find method in VBA.