2nd delete not working...

ValpoMan

New Member
Joined
Jun 25, 2010
Messages
46
I have the following code...the second DO...IF...LOOP (Dim D) is not doing the delete...it does do the first one correctly....

Sub Master()
'
' Master Macro
'
' Keyboard Shortcut: Ctrl+m
'
Sheets("Do Not Adjust-Only Copy").Copy After:=Sheets(2)
Application.ScreenUpdating = False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A4") = Now
ActiveSheet.Name = Format(Now, "mm-dd-yyyy hh-mm")
Range("U8").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(RC[-13]:RC[-1])=0,""true"",)"
Selection.Copy
Range("U8:U4842").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Dim c As Range
EndRow = Range("U5000").End(xlUp).Row
Do: Set c = Range("U8:U" & EndRow & "").Find("true", LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If c Is Nothing Then Exit Do
c.EntireRow.Delete
Loop
Columns("V:BC").Select
Selection.Delete Shift:=xlToLeft
Range("U8").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-16]>1,"""",""true"")"
Range("U8").Select
Selection.Copy
Range("U8:U1000").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Dim d As Range
EndRow = Range("U1000").End(xlUp).Row
Do: Set d = Range("U8:U" & EndRow & "").Find("true", LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If d Is Nothing Then Exit Do
d.EntireRow.Delete
Loop
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

ValpoMan

New Member
Joined
Jun 25, 2010
Messages
46
Maybe there is a way I can combine those loops so it does both deletes at the same time but it's above my level...
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Can't you just use an AutoFilter macro for "true" and delete rows with SpecialCells(xlTypeVisible)?? Something like
Code:
Range("U8:U" & EndRow).AutoFilter Field:=1, Criteria1:="true"
Range("U8:U" & EndRow).SpecialCells(xlTypeVisible).EntireRow.Delete

lenze
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,927
Messages
5,834,404
Members
430,282
Latest member
MeredithD26

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