Macro to delete 3 rows if macro is wrong?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Yes basicly I'm trying to delete all the rows where C has a title but D,E,F don't and my data has two rows of blank data between it so to keep it looking the same i need to get rid of the two rows below as well.
 
Upvote 0
Yes basicly I'm trying to delete all the rows where C has a title but D,E,F don't and my data has two rows of blank data between it so to keep it looking the same i need to get rid of the two rows below as well.
Do all the cells in Columns D, E and F have to be empty in order to have the row deleted?
 
Upvote 0
Ok So Let say C7 has data in it, if any of D7,E7,F7 have data i need that data, BASICLY Column C is just Headers or Titles, Column D,E,F are important info about that Title, so if I don't have any info I don't need the Title.
So what I'm trying to do is go down the Titles and remove the ones that don't hold any info, now for reasons I do not understand the data is set up as Title the two empty rows then next title then two empty rows etc so if I just delete Row 7 Id have 4 empty rows and it would look wrong. so i need to delete the three rows

Thanks

Tony
 
Upvote 0
This confuses me:
You said:
Yes basicly I'm trying to delete all the rows where C has a title but D,E,F don't

What is a title?

Do you mean a value

Or do you mean has some value in the header to the column which is normally row (1)
 
Upvote 0
Maybe this example will help sorry if i'm being unclear.

A
B
C
D
E
F
G
H
I
1
Title
Value1
Value2
Value3
What I need to happen
2
Magic Man
H17ty
2500p
Keep as is
3

Keep as is
<strike></strike>

<strike></strike>
4
Keep as is
<strike></strike>

<strike></strike>
5
Door Closer
Delete row because D E F are all empty
6
delete row because above was deleted
7
Delete row because above was deleted
8
Rubber Bucket
T56765
&yty
88iu
Keep
9

Keep
10

Keep
11
TV stand
p890
5664T
Keep
12
Keep
13
Keep
14
Door Handel 7
Delete
15
Delete
16
Delete
17

and so on so that every time column C contains data but DEF do not it deletes
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

<tbody>
</tbody>
 
Upvote 0
Try this:
Code:
Sub Test()
'Modified 3-26-18 6:25 AM EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
    For i = Lastrow To 2 Step -1
        If Cells(i, "C").Value <> "" And Cells(i, "D").Value = "" And Cells(i, "E").Value = "" And Cells(i, "F").Value = "" Then
            Rows(i).Resize(3).Delete
        End If
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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