delete entire row if any of 3 criterea are met

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,104
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hello everyone and anyone.

i want to create a code that deletes the entire row if

1, date in column A is equal to or newer than date in SHEET("APP") CELL ("C3")
2, text in column H does not match or equal text in SHEET("APP") CELL ("C2")
3, the 1st letter in coulumn M is not the letter "A"

I will probably manage to sort this out eventually, but im running out of time.
Not to mention, it would not be a very neat code.
I would probably do it in 3 loops.

any professional help will be greatly appriciated.

Dave
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
i want to create a code that deletes the entire row if

1, date in column A is equal to or newer than date in SHEET("APP") CELL ("C3")
2, text in column H does not match or equal text in SHEET("APP") CELL ("C2")
3, the 1st letter in coulumn M is not the letter "A"
Your thread title and the above description makes it unclear whether all of those conditions must be met or if only any one (or more) of them are met... which is it?
 
Upvote 0
Hello Rick

Hope you had a good christmas

sorry for not being clearer

if any of those conditions are met, so i want all newer dates or same date gone, all that do not match in column H and all that do nt have A as the 1st charracter.
if i was to write 3 codes, it would work.

please see what i have so far below
Code:
Sub Delete()
Dim LR As Long

Application.ScreenUpdating = False
    
    For LR = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Range("A" & LR).Value >= Range("'app'!$c$3") Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
    
    For LR = Range("H" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Range("H" & LR).Value <> Range("'app'!$c$2") Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
    
Application.ScreenUpdating = True
End Sub

just havent worked out the A problem yet in comment 3

But like i said, it will be messy.

thanks rick

Regards

dave
 
Upvote 0
Ok

so i have now got this far,

Code:
Sub Delete()
Dim LR As Long

Application.ScreenUpdating = False
    
    For LR = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Range("A" & LR).Value >= Range("'app'!$c$3") Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
    
    For LR = Range("H" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Range("H" & LR).Value <> Range("'app'!$c$2") Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
    
    For LR = Range("M" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Left(Range("M" & LR), [1]) <> "A" Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0
baby steps lol

think im there, unless anyone can see something wrong with it

Code:
[CODE] For LR = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Range("A" & LR).Value >= Range("'app'!$c$3") Or Range("H" & LR).Value <> Range("'app'!$c$2") Or Left(Range("M" & LR), [1]) <> "A" Then
            Rows(LR).EntireRow.Delete
        End If
    Next LR
[/CODE]

dave
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top