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.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Did you get that error on the previous code?
 
Upvote 0
In that case has anything changed in your data, as that line of code has not changed.
 
Upvote 0

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,
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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