
The Find method will return the Range object, which represents the cell in which a value first occurred. monetary standard, number, border, fill, alignment, etc.). The parameter can be True or False depending on whether or not a format is assigned (e.g.
SearchFormat: This parameter is optional. Case-sensitive searches should be set to True. The two values for this argument are True and False. MatchCase: This parameter is optional. The two constants are xlNext, which is used to search a subsequent value in the range, and xlPrevious, which is used to search a value stated previously. This parameter indicates the direction of search in a particular range. SearchDirection: This parameter is optional. The search order is subject to two constants: xlByRows (for rows), or xlB圜olumns (for columns). SearchOrder: This parameter is optional. In contrast, to indicate you are searching for values that contain 10 (in this case, 6210 or 4105), you can use LookAt:=XlPart. 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.