Excel VBA Macro: Delete Rows (Based on List of Values)

  Рет қаралды 607

greggowaffles

greggowaffles

4 ай бұрын

Excel VBA Macro: Delete Rows (Based on List of Values)
💥Subscribe: / @greggowaffles
Code:
Sub delete_rows_based_on_list()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim row_count1 As Long
Dim row_count2 As Long
Dim i As Long
Dim j As Long
Set ws1 = ThisWorkbook.Sheets("Stock Screener")
Set ws2 = ThisWorkbook.Sheets("Items to Delete")
ws2.Activate
row_count2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
ws1.Activate
row_count1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
For j = 1 To row_count2
i = 2
Do While i <= row_count1
If Cells(i, 10) = ws2.Cells(j, 1).Text Then
Rows(i).EntireRow.Delete
i = i - 1
row_count1 = row_count1 - 1
End If
i = i + 1
Loop
Next j
End Sub
#excelmacro #excelvba

Пікірлер: 6
@alexrosen8762
@alexrosen8762 4 ай бұрын
Your tutorials are really great and super useful 👌I can see a lot of use cases for this specific example in a lot of real world scenarios
@greggowaffles
@greggowaffles 4 ай бұрын
Thanks! Appreciate the feedback as always!!
@Dexter101x
@Dexter101x 4 ай бұрын
Oh you're back
@greggowaffles
@greggowaffles 2 ай бұрын
😎😎
@justlooking717
@justlooking717 4 ай бұрын
I tried using the code in your tutorial with a data table I am working with and did not work. This is my first attempt at using a macro to automate anything in excel so I am sure I am doing something wrong. I tried running in step and it highlights the Sub line. The table I am working with has order entries each listing the operations associated with these orders. Several operations in some orders do not have a scheduled start date, which is essential for the project I am doing so I need to delete the rows missing the start date and any operations associated with the order that had a "defective" operation. From your video I got the impression that your script would do this task but I can't make it work. Any advice?
How to get the Last Row in VBA(The Right Way!)
15:41
Excel Macro Mastery
Рет қаралды 154 М.
10 awesome Power Query tricks you NEED to know! | Excel Off The Grid
15:44
Excel Off The Grid
Рет қаралды 34 М.
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 8 МЛН
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 25 МЛН
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 82 МЛН
5 Excel Secrets You'll Be Embarrassed You Didn't Know
17:32
Excel Campus - Jon
Рет қаралды 126 М.
Excel VBA Macro: Insert PivotTable (in Email Body)
9:19
greggowaffles
Рет қаралды 599
How to Get List of File Names in a Folder using Excel
5:40
Excel Weez
Рет қаралды 6 М.
Excel VBA Macro: Save Range (as Image) and Attach to Email
12:15
6 Excel Tools Most Users Never Think to Use (Files Included)
12:34
MyOnlineTrainingHub
Рет қаралды 143 М.
3 Easy Ways to Delete Blank Rows in Excel ✅
12:13
TrumpExcel
Рет қаралды 20 М.
10 Excel Formulas That Will Set You Apart (Cheat Sheet)
18:04
MyOnlineTrainingHub
Рет қаралды 229 М.
3 Essential Excel skills for the data analyst
18:02
Access Analytic
Рет қаралды 1,5 МЛН
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 8 МЛН