delete row based on 3 criteria

JOEE1979

Active Member
Joined
Dec 18, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
This is way out of my league, and I need help please.

Here is what I'm looking to do;

If there is a number in "T5" and nothing in "A5" & "K5" & "U5" (all 3 have to be blank),
Then delete entire row
(I would like this to continue until end, every sheet has a different amount of lines)

***I would like this to be a 1 time event and not re-occur)***


Thank you

Weekday Bus Cycling - Revision2.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1Current Time22:28Ready Units in Barn1Good UntilTomorrowNext DepartureTomorrowAberfoyle-MON-WED0
2Required ByRequired Units0Units Returning0Total Required0Total Returning13 
3BlockTypeOp DaySign onStartEndVehKmNoteBlockTypeOp DaySign onStartEndVehKmNoteBlockTypeOp DaySign onStartEndVehKmNoteTotal KMTimeOUTIN
4Super Low Top - Double DeckerDDSDDSDDS5877.460:01-0:3000
5MDDS2101REGmuwtf3:474:0511:47DDS251.74RPT1MDDS2104RELmuwtf14:1714:350:26DDS393.091aberf005RELmuwtf13:2413:4221:20DDS224.54869.360:31-1:0000
6DDS21001REGmuwtf4:324:5015:05DDS383.982MDDS2106RELmuwtf15:2115:3923:15DDS275.562aberf006RELmuwtf14:0214:2023:55DDS342.851002.39
7DDS21002REGmuwtf5:325:5015:40DDS383.983MDDS2108RELmuwtf16:0216:203:01DDS380.633aberf007RELmuwtf14:4715:050:35DDS385.661150.27
8DDS21003REG/SPLTmuwtf6:477:0519:05DDS405.9244405.92
9MDDS2103REG/REL/REG/RELmuw6:477:0522:55DDS599.5455599.54
10MDDS2102REG/RELmuwtf5:576:151:00DDS653.4266653.42
117MDDS2105RELmuwtf14:3214:5023:35DDS403.607403.60
128MDDS2107RELmuwtf15:2415:422:35DDS425.738425.73
139MDDS2109RELmuwtf16:0716:252:16DDS367.249367.24
14 
15 
16 
17020602
Aberfoyle-MON-WED
Cell Formulas
RangeFormula
C1C1=Planner!$C$1
N1N1=HLOOKUP($Z$1,Planner!$C$3:$AL$7,5,FALSE)
T1T1=HLOOKUP($Z$1,Planner!$C$3:$AL$7,2,FALSE)
AI1AI1=SUM((COUNTIFS($D$5:$D$16,">="&Planner!$C$1,$D$5:$D$16,"<="&$N$1))+(COUNTIFS($N$5:$N$16,">="&Planner!$C$1,$N$5:$N$16,"<="&$N$1))+(COUNTIFS($D$22:$D$32,">="&Planner!$C$1,$D$22:$D$32,"<="&$N$1))+(COUNTIFS($N$22:$N$32,">="&Planner!$C$1,$N$22:$N$32,"<="&$N$1))+(COUNTIFS($X$5:$X$16,">="&Planner!$C$1,$X$5:$X$16,"<="&$N$1))+(COUNTIFS($X$22:$X$32,">="&Planner!$C$1,$X$22:$X$32,"<="&$N$1)))
I2I2=SUM((COUNTIFS($D$5:$D$16,">="&Planner!$C$1,$D$5:$D$16,"<="&$C$2))+(COUNTIFS($D$22:$D$32,">="&Planner!$C$1,$D$22:$D$32,"<="&$C$2))+(COUNTIFS($N$5:$N$16,">="&Planner!$C$1,$N$5:$N$16,"<="&$C$2))+(COUNTIFS($N$22:$N$32,">="&Planner!$C$1,$N$22:$N$32,"<="&$C$2))+(COUNTIFS($X$5:$X$16,">="&Planner!$C$1,$X$5:$X$16,"<="&$C$2))+(COUNTIFS($X$22:$X$32,">="&Planner!$C$1,$X$22:$X$32,"<="&$C$2)))
M2M2=SUM((COUNTIFS($F$5:$F$16,">="&Planner!$C$1,$F$5:$F$16,"<="&$C$2))+(COUNTIFS($F$22:$F$32,">="&Planner!$C$1,$F$22:$F$32,"<="&$C$2))+(COUNTIFS($P$5:$P$16,">="&Planner!$C$1,$P$5:$P$16,"<="&$C$2))+(COUNTIFS($P$22:$P$32,">="&Planner!$C$1,$P$22:$P$32,"<="&$C$2))+(COUNTIFS($Z$5:$Z$16,">="&Planner!$C$1,$Z$5:$Z$16,"<="&$C$2))+(COUNTIFS($Z$22:$Z$32,">="&Planner!$C$1,$Z$22:$Z$32,"<="&$C$2)))
Q2Q2=SUM($D$17,$N$17,$D$33,$N$33,$X$17,$X$33)
U2U2=SUM($F$17,$P$17,$F$33,$P$33,$Z$17,$Z$33)
Z1Z1=MID(CELL("filename",$V$1),FIND("]",CELL("filename",$V$1))+1,32)
Z2Z2=IF($AI$1>$J$1,"Will require "&(SUM($AI$1-$J$1))&" more units for "&TEXT($N$1,"hh:mm")&" service","")
AH4:AH5AH4=SUM((COUNTIFS($D$5:$D$13,">="&AE4,$D$5:$D$13,"<="&AG4))+(COUNTIFS($D$16:$D$23,">="&AE4,$D$16:$D$23,"<="&AG4))+(COUNTIFS($N$5:$N$26,">="&AE4,$N$5:$N$26,"<="&AG4))+(COUNTIFS($N$29:$N$43,">="&AE4,$N$29:$N$43,"<="&AG4))+(COUNTIFS($X$5:$X$21,">="&AE4,$X$5:$X$21,"<="&AG4))+(COUNTIFS($X$24:$X$48,">="&AE4,$X$24:$X$48,"<="&AG4)))
AI4:AI5AI4=SUM((COUNTIFS($F$5:$F$13,">="&AE4,$F$5:$F$13,"<="&AG4))+(COUNTIFS($F$16:$F$21,">="&AE4,$F$16:$F$21,"<="&AG4))+(COUNTIFS($P$5:$P$22,">="&AE4,$P$5:$P$22,"<="&AG4))+(COUNTIFS($P$25:$P$37,">="&AE4,$P$25:$P$37,"<="&AG4))+(COUNTIFS($Z$5:$Z$19,">="&AE4,$Z$5:$Z$19,"<="&AG4))+(COUNTIFS($Z$22:$Z$29,">="&AE4,$Z$22:$Z$29,"<="&AG4)))
AD4AD4=SUM(AD5:AD16)
AD5:AD16AD5=IF((SUM(H5,R5,AB5))=0,"",SUM(H5,R5,AB5))
D17,Z17,X17,P17,N17,F17D17=COUNTIF(D5:D16,">="&Planner!$C$1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AI4:AI51Cell Value>0textNO
AH4:AH51Cell Value>0textNO
AH4:AI51Cell Value=0textNO
N1:O1Cell Valuecontains "Tomorrow"textNO
D5:D16,N5:N16,X5:X16,D22:D32,N22:N32,X22:X27,X31:X32Expression=D5=$N$1textNO
D5:D16,N5:N16,X5:X16,D22:D32,N22:N32,X22:X27,X31:X32Cell Valuebetween Planner!$C$1 and $N$1textNO
D5:D16,N5:N16,X5:X16,D22:D32,N22:N32,X22:X27,X31:X32Cell Value>Planner!$C$1textNO
F5:F16,P5:P16,Z5:Z16,F22:F32,P22:P32,Z22:Z27,Z31:Z32Cell Value>Planner!$C$1textNO
Cells with Data Validation
CellAllowCriteria
J1Whole number>0
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Dont have excel atm, so UNTESTED
VBA Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "T").End(xlUp).Row
For r = lr To 5 Step -1
    If IsNumber(Range("T" & r)) And Range("A" & r) = "" And Range("K" & r) = "" And Range("U" & r) = "" Then
        Rows(r).Delete
    End If
Next r
End Sub
 
Upvote 0
I get a message
Sub or function not defined

IsNumber (is highlighted)

***Also, how would I make this for entire workbook?***
 
Upvote 0
still untesteed
VBA Code:
Sub MM1()
Dim lr As Long, r As Long, ws As Worksheet
For Each ws In Worksheets
lr = ws.Cells(Rows.Count, "T").End(xlUp).Row
With ws
For r = lr To 5 Step -1
    If .Range("T" & r) <> "" And .Range("A" & r) = "" And .Range("K" & r) = "" And .Range("U" & r) = "" Then
        .Rows(r).Delete
    End If
Next r
End With
Next ws
End Sub
 
Upvote 0
Solution
still untesteed
VBA Code:
Sub MM1()
Dim lr As Long, r As Long, ws As Worksheet
For Each ws In Worksheets
lr = ws.Cells(Rows.Count, "T").End(xlUp).Row
With ws
For r = lr To 5 Step -1
    If .Range("T" & r) <> "" And .Range("A" & r) = "" And .Range("K" & r) = "" And .Range("U" & r) = "" Then
        .Rows(r).Delete
    End If
Next r
End With
Next ws
End Sub
worked, awesome, thanks
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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