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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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