Excel VBA Macro : Find Cell Value in a List with Excel Worksheet Function CountIf
With this Excel Macro VBA you can use built-in Excel functions, ie the macro will invoke native Excel methods to operate in Excel worksheets.
-About the VBA editor Excel We declare a variable last row of type long. Esta variable will serve to save a numerical value of Excel that indicates the last row in the Excel sheet. -We set the range of Excel cells with cells B2 to B5 (it is the range where we will look for matches in the list of Excel values.
-We set the variable cell parameter to indicate the value to be searched in the Excel sheet.
- We create a conditional IF .. where we ask if there is a match If there is a match, the value returned by the Excel function will be greater than zero.
-Then we return a -Then we return a message box in the Excel worksheet indicating the range of cells.
-This Excel vba macro operates quickly and easily on the worksheets.
-You can customize and use this Excel macro in various ways in Excel database to set limits in an Excel database.
-You can add a dialog box using Excel VBA and invoke this macro to operate in a simpler way.
-You can include a button on the ribbon ribbon and invoke the macro using a VBA Excel call. Optionally you could have a personal macro book.
-You can have a book with extension xls or a book with extension .xlsm ..other book formats Do not support saving macros.
-I recommend you check the code line by line from the Excel vba editor -When checking the code line by line you can understand better.
-To review your VBA Excel code line by line press F8 from the VBA editor. So you know what this Excel macro is about and how it works On the Excel worksheet.
-If you want to run everything at once press F5 from the VBA code editor and the code finds the Excel cells with matches.

Sub MacroFindExcelValue()

'Macro with Excel Worksheet Function CountIf and messagebox function VBA

Dim LastRow As Long39;get last excel row used
'LastRow = Range("C1").End(xlDown
‘get last row in excel rows '

'find cell value in the list -' VBA Excel Macro
Dim Range_List As Range, Cell_Parameter As Range
Set Range_List =Range("B2:B5")
SSet Cell_Parameter = Range("C2")

If Application.WorksheetFunction.CountIf(Range_List, Cell_Parameter) > 0 Then
    MsgBox "Excel cell value - It was found the parameter " & Cell_Parameter.Value & ", Excel - cell address: " & Cell_Parameter.Address(False, False) & " in the list " & Range_List.Address(False, False)

End Sub