Locate matched criterea & delete Rows!

Zshanar69

New Member
Joined
Apr 28, 2020
Messages
17
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi,
I have master sheet called "ENTITY"
In column "A" if there's a text "NEXT" but in the same Row column "B" is empty.
now there may be 3 or 300 or 3000 Rows with same criteria,
I want last entry to be found with same criteria & right below that row column "D" ,"G" & "K" must be cleared without changing other cells in single Row,
& below that
every Row to last filled row of column "A" would be deleted!
if anyone could please suggest any VBA macro!

Thanks.
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,314
Office Version
  1. 365
Platform
  1. Windows
Did you get that error on the previous code?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,314
Office Version
  1. 365
Platform
  1. Windows
In that case has anything changed in your data, as that line of code has not changed.
 

Zshanar69

New Member
Joined
Apr 28, 2020
Messages
17
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
  3. Web

Ok, how about
VBA Code:
Sub Zshanar()
   Dim Rng  As Range
   Dim UsdRws As Long
  
   With ActiveSheet
      UsdRws = .Range("A" & Rows.Count).End(xlUp).Row
      .Range("A1:B" & UsdRws).AutoFilter 1, "next"
      .Range("A1:B" & UsdRws).AutoFilter 2, ""
      Set Rng = Range("A" & Rows.Count).End(xlUp)
      .AutoFilterMode = False
   End With
   Intersect(Rng.Offset(1).EntireRow, Range("D:D,G:G,K:K")).ClearContents
   Range(Rng.Offset(2), Range("A" & UsdRws)).EntireRow.Delete
End Sub
Nothing changed in data, your previous code had autofilter lines .Range(A:B now its A1:B I replaced both & code works just fine!
Thanks,
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,314
Office Version
  1. 365
Platform
  1. Windows
Glad you sorted it & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,359
Messages
5,601,157
Members
414,431
Latest member
JustmemyselfandI

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
Top