Macro to delete 3 rows if macro is wrong?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,197
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I'm looking fo a macro that in sheet "report" goes down column C
and finds each row that contain data in column C,
The looks to see if there is any data in columns D,E,F of that same row,

if there are great move on to the next if not delete the row and the two rows under it.

any ideas how this can be done?

Thanks

Tony
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
TitleValue1Value2Value3What I need to happen
Magic ManH17ty 2500pKeep as is
Keep as is
Keep as is
Door Closer Delete row because D E F are all emptyDD
delete row because above was deletedD
Delete row because above was deletedD
Rubber BucketT56765&yty88iuKeep
Keep
Keep
TV standp8905664T Keep
Keep
Keep
Door Handel 7 DeleteDD
DeleteD
DeleteD
I have used helpers to mark rows for deletion
this is before macro runs

<colgroup><col><col><col><col span="3"><col><col span="3"><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
TitleValue1Value2Value3What I need to happen
Magic ManH17ty 2500pKeep as is
Keep as is
Keep as is
Rubber BucketT56765&yty88iuKeep
Keep
Keep
TV standp8905664T Keep
Keep
Keep
I have used helpers to mark rows for deletion
this is after this macro runs
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 26/03/2018 by bob
'
'
j = 1
10 j = j + 1
If j > 25 Then GoTo 100
If Cells(j, 10) = "D" Then Cells(j, 11) = "D": Cells(j + 1, 11) = "D": Cells(j + 2, 11) = "D": j = j + 2: GoTo 10
GoTo 10
100 For k = 25 To 2 Step -1
If Cells(k, 11) = "D" Then GoTo 50 Else GoTo 200
50 Rows(k).Select
Selection.Delete Shift:=xlUp
200 Next k
End Sub

<colgroup><col><col><col><col span="3"><col><col span="3"><col><col><col><col span="4"></colgroup><tbody>
</tbody>
 
Upvote 0
I think you may already have a working solution, but for the record, this is how I write the macro...
Code:
[table="width: 500"]
[tr]
	[td]Sub DeleteTitlesWithNoData()
  Dim LastRow As Long, Cell As Range
  LastRow = Cells(Rows.Count, "C").End(xlUp).Row
  Application.ScreenUpdating = False
  On Error GoTo NoTripleBlanks
  Range("C2:C" & LastRow) = Evaluate(Replace("IF(C2:C@="""","""",IF((D2:D@="""")+(E2:E@="""")+(F2:F@=""""),""#N/A"",C2:C@))", "@", LastRow))
  For Each Cell In Columns("C").SpecialCells(xlConstants, xlErrors)
    Cell.Resize(3).Value = "#N/A"
  Next
  Columns("C").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
NoTripleBlanks:
  Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,273
Members
449,220
Latest member
Excel Master

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