If you are seriously after a VBA code to help you out in order to delete all the rows based on specific text found in a particular column, then this article is for you. In this article, we will learn how to delete a row if the specific text is found in a column.
Question): I have a file where I just need those rows which have “Product B” in column B. I want to delete everything else. Can someone please help me to write a macro? Following is the snapshot of data we have:
We need to follow the below steps:
Enter the following code in the standard module:
.AutoFilter 1, "<>Product B"
Step 1) The above code will select current region from column 2 i.e. Product column
Step 2) Apply Filter
Step 3) The visible cells will be deleted with entire row. Delete code. Rest of the data i.e. where Product B exists in column B will be our output.
In this way, using VBA code, we can delete rows meeting specific conditions.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.