Excel VBA - Find specific text in cell

preview_player
Показать описание
How to perform string search using InStr() function in Excel VBA?
We can also allow users to decide what to look for and clear/delete those cells that contain specific character/text/letter/string.

*Components of InStr([start], string1, string2, [compare]):
1. start - position of a particular character in a spring that we wish to start at
2. string1 - string that going to be checked
3. string2 - character that we looking for
4. compare - "0" for case-sensitive; "1" for non-case-sensitive
*Remark: [start] and [compare] are optional.

Example:
a = InputBox("Check for specific character/string")
For Each cell In Range(Cells(1, 1), Cells(3, 3))
If Not InStr(cell, a) = 0 Then
MsgBox ("Invalid input found")
Exit Sub
End If
Next
MsgBox ("No invalid inputs are found")

----------------------------------------------------------------------------------------------------------
code to show certain cells:
MsgBox ("Invalid input found in cell(" & i & ", " & j & ")")
Рекомендации по теме
Комментарии
Автор

Hi I used instr function but my program is not able to find different between CL300 and CL3000. Any alternative or solution.

vinodtechnoclub