VBA Macro to Delete Rows Based on Cell Values

preview_player
Показать описание


This is a simple two step process to apply a filter to a range or Table, then delete the visible rows. In the video I explain the VBA code to automate the process with a macro.

I also share more a few advanced macros that:
1. Display a message box with the number of rows to be deleted.
2. Apply filters to multiple columns to delete cells based on multiple conditions or criteria.

To filter the range or Table we use the AutoFilter method in VBA.

We then use the SpecialCells method to select the visible cells and delete the entire rows from the range.

****Free webinar on Macros & VBA****

If you're new to macros and/or want to learn more, join me for a free upcoming webinar on "The 7 Steps to Getting Started with VBA".

You will learn how to write your first macro and go beyond the limitations of the macro recorder.

****************************************************************

Here are some links and resources:

00:00 Introduction
00:10 VBA Macro to Delete Rows Based on Cell Values
01:01 The Process Explained
05:43 The VBA Macro Code
Рекомендации по теме
Комментарии
Автор

Thanks for describing the possibility of deleting rows with VBA so precisely

ExceliAdam
Автор

Thank you. Very helpful. If you can provide versions of this for different scenarios (eg, already active sheets as well as new sheets), this would be helpful. Great video.

guideglobal
Автор

Great video ! Working absolutely fine, thanks a ton !

Автор

Another awesome, well-explained video. Thank you Jon.

tannertucker
Автор

Thank you, this is so much easier than trying to write a loop. How about a scenario where a column contains rows with either text or numbers and delete only those where the cell contains text only?

michaelmurphy
Автор

Thank you very much, very useful video

Trupticool
Автор

Hi Jon, I would like the field to apply to multiple columns, do I simple add Field:4, 5, 6 for example?

sonyarodriguez
Автор

This is excellent Jon. Thank you. Do you how I can use vba (without the autofilter) to delete rows that have a cell in column A with a blank OR a date (any date in it)? Thank you.

anthonylobello
Автор

Question - Say I want to run a “does not begin with” filter and then delete all those rows. How do you go about doing that? Thanks!

Msantora
Автор

Simply Superb. Very useful for me. Appreciate it :-)

srinivasannarayanaswami
Автор

Your lessons are fantastic. Do you know how to edit the code to delete the entire row if the row contains a cell in column B with a strike through please?

tannertucker
Автор

Is there a way to prevent the macro from going into debug mode when no target values are present? Say I am targeting blanks and there isn't any blanks. If the button is hit it goes into debug mode.

HowtoHacks
Автор

Can it delete rows that meet IF logic? E.g if column C date is less than column G date, then delete.

canefan
Автор

Your Very Good !! :) Thank You from SO !! :)

redfeathersa
Автор

Another great video Jon! Thanks so much for the help! Keep the lessons coming please!! :). I'm curious- why you didn't use Current Region rather than cell values when defining the range. Thanks!

scottgaines
Автор

How do I apply AutoFilter for all rows with dates prior to today's date in VBA, then delete the rows?

yisrael
Автор

What if No Data "Product 2" in the selected range to delete! will macro stop? Or it will proceed with next step. How to record macro for this check?

Sarfoo
Автор

Hi Jon, great video. I have a question. I have a spreadsheet with about 9, 000 people on it that consist of male, females and their addresses. I need to delete only the males from this spreadsheet. How do I create a formula for that.

lenorawillis-photonobics
Автор

If i wanted to use two cells side by side as a simple calculator I.e put the number 3 in the left cell and it gets added to the right cell while also removing the 3 so the cell can be used again, how would one do that?

Railien
Автор

Taking advantage of the availability of help, I am having difficulties in this topic:
Any delete in "PPP" product, on main data in table(sheet1), the same must be happen in the sheet table of the product "PPP" on sheet2. The ID of the rows are different in each tables. How to to do that?
Have you any video to solution that?
Thank you Mr jon

carlosgaspar