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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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...
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,217,682
Messages
6,137,959
Members
450,101
Latest member
Mrupe86

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