

In the above code we used the InputBox function to obtain the search string input from the user. You can also use this script and tweak it to suit your own requirements. Now that your required rows are selected you can go ahead and perform whatever actions you need to with them. From the Developer tab, select Visual Basic.To enter the above code, copy it and paste it in your developer window. In case you look for the word ‘king’, it will not be able to find it and show you a message box letting you know that it couldn’t find the specified text.

Note that the above code is case sensitive. The above macro loops through each cell in a range and selects only the rows that contain the text “ King”. MsgBox "The text was not found in the selection"

Set myUnion = Union(myUnion, m圜ell.EntireRow) SearchString = InputBox("Please Enter the Search String") The following code will help you select rows with specific text in Excel. To use this code, you need to first select the data where you want to select rows with specific text and then run this code. We have already prepared the code that you need to use, so all you need to do is just navigate to the Developer window, copy-paste the code, select the data that you want to work on and run the code. Using VBA to Select Rows with Specific Text in Excel Here are two ways to tackle this problem. Given the above data, let us say you want to find and select all the rows that contain the word “ King” in them.
