Delete Rows based on Value/Text // Excel VBA Tutorial

preview_player
Показать описание
In this video I am showing you how to delete rows based on value or text. The code is the following:
Sub delete_rows()

For i = 2 To Sheets(2).UsedRange.Rows.Count
If Cells(i, 3).Value = "No" Then
Rows(i).EntireRow.Delete
End If
If Cells(i, 3).Value = "No" Then
Rows(i).EntireRow.Delete
End If
Next i

End Sub
Рекомендации по теме
Комментарии
Автор

Hello guys and gals! I am sorry for the black screen at the end, I suppose I messed up something while editing. The video ends at 4:15!

FinanceNik
Автор

Finally! A simple, concise Excel video with code that's general enough to easily modify. Works perfectly. Thanks.

knglerxst
Автор

Kia Ora! Thanks for a very helpful video. How would you edit the code to delete cell that have a value after a particular date? Eg. delete dates after 11/06/2101 (dd/mm/yyyy) from a data set

MichelleBarry-ex
Автор

Hi Thank you for the video - it was very helpful. I have a question - is there a way to do the same for text file (.txt extension) search 1st word (text) and search 2nd word (text) and in between the range want to remove and save the file - PLEASE advise! Thank you for your help! - Dalpat

dalpatmistry
Автор

Thank you so much Nik Helped me a lot after a lot of searching in different videos

garrgapify
Автор

Hello! Please tell me if the GoalSeek macro written in VBA works in Microsoft Excel for Mac and, in particular, for the version for devices running on the Apple Silicon M1 processor. I often use it to calculate additional financing for the cash gap when building financial models due to my profession. I will be very grateful if you make a video with such a macro and check its work, as I heard that in the version of Excel for Mac, there are problems with this macro.
And also it will also be interesting to see if Power query works the same way in Excel for Mac as it does in the Windows version.
Thank you for the content. Very useful videos, on the vastness of YouTube there are few useful videos about using office programs on a Mac

МаксимМ-тй
Автор

It is not working when I have more than 3-4 rows in a line to delete

stohajunwa
Автор

Data Nik, thank you for the video, it was very helpful. I have a question. Is there a way to do a partial clear of data, in a row up to a certain phrase and be able to keep all the data that follows that point? And, could that code to seek out a phrase that would just target those rows to be cleared? I apologize if I am being redundant...just want to be as clear as possible.

jonperez
Автор

Hi, very nice video.
I have a question:
what if I need to apply this macro for a multiple criteria on the same column "example, i need to cancel all the rows based on the texts "Bread, orange, cake, ".
Also, what if my range is over 250000 lines? Many thnaks

fabiothescience
Автор

This is actually awesome! I have a question though. I've been trying to find someone who knows how to do this in excel forever. So I'm in SEO and a common problem I come across whenever consolidating backlink data is going through thousands of URLs and deleting rows with unwanted Top-Level Domains (.surf, .gq, .bid, .tw, etc...). What I've resorted to doing is the eye bleed method of CTRL + F, Search TLD "find all", CTRL+ A, then CTRL + -. Repeat steps for like 50 different unwanted TLDs... My question is if I'm given a list of URLs, is it possible to do a similar process you show in your video but to delete URLs that end with a "list" of specified TLDs, while also deleting the rows associated with them?

redspectrenine
Автор

Thank you ! How do I delete all rows except for Header Rows?

tlee
Автор

Hi - is there a way to change the range to apply to an entire column rather than the used range? Thanks

geegeejeep
Автор

The problem i am having is that the empty rows i have are zero value based on formula.
so, when i ma using the code, its deleting every thing. any advise.

My 1st row is row 8

this is the code i am using



Sub Delete_Rows()

Dim lastrow As Long, xrow As Long
xrow = 8

lastrow = Range("a400").End(xlUp).row
Do Until xrow = lastrow
If Cells(xrow, 8).Value = "" Then
Cells(xrow, 8).Select
Selection.EntireRow.Delete
xrow = xrow - 1
lastrow = lastrow - 1
End If
xrow = xrow + 1
Loop

End Sub

chadiabou-ghayda
Автор

Is there a way to change vba code to let this macro run on whatever sheet you are on instead of the first tab?

excelgladiator
Автор

Hey, I need to do something similar but instead of yes/no, I need to delete rows that contain any date in the "I" column. Could you help?

Andromeda-twlb
Автор

sir the font is si small nearly invisible pl enlarge whic could easily be watched dont mind sir

AbdulKarim-msxb
Автор

Hi, I am getting type mismatch error when I try to include OR so that I can search and delete multiple names

abutahir
Автор

What's wrong, it won't delete the rows in column A with the words Date in them. Nothing happens actually.

Sub DeleteRowswithTextDate()

For i = 1 To
If Cells(i, 1).Value = "Date" Then
Rows(i).EntireRow.Delete
End If
Next i
End Sub

BambooScar