Remove data

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hello all,

Good day.

In c drive i have 1 excel file.

Excel file Name : "acd.xls"

I Need to open and delete entire row.

Condtion : AA row contain "ZR" i need to delete entire row .

save the excel and close the excel.

Please help/.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about
Code:
Sub OpenDel()

   Dim wb As Workbook
   
   Set wb = Workbooks.Open("[COLOR=#ff0000]C:\MrExcel\acd.xls[/COLOR]")
   With wb.Sheets("Sheet1").Range("AA:AA")
      .Replace "*ZR*", "=XXX", xlPart, , False, , False, False
      .SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
   End With
   wb.Close True
   
End Sub
 
Upvote 0
How about
Code:
Sub OpenDel()

   Dim wb As Workbook
   
   Set wb = Workbooks.Open("[COLOR=#ff0000]C:\MrExcel\acd.xls[/COLOR]")
   With wb.Sheets("Sheet1").Range("AA:AA")
      .Replace "*ZR*", "=XXX", xlPart, , False, , False, False
      .SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
   End With
   wb.Close True
   
End Sub

Out of stack space error : 28...

Please help.
 
Upvote 0
How about this
Code:
Sub OpenDel()

   Dim wb As Workbook
   
   Set wb = Workbooks.Open("C:\MrExcel\acd.xls")
   With wb.Sheets("Sheet1")
      With .Range("AA1", .Range("AA" & Rows.Count).End(xlUp))
         .Replace "*ZR*", "=XXX", xlPart, , False, , False, False
         .SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
      End With
   End With
   wb.Close True
   
End Sub
 
Upvote 0
Hi Fluff,

thank you. it's working now.

I need 1 small change...

I need to delete previous Row also. ( Current row & Previous row ).

Please help
 
Last edited:
Upvote 0
Ok, try
Code:
Sub OpenDel()

   Dim wb As Workbook
   
   Set wb = Workbooks.Open("C:\MrExcel\acd.xls")
   With wb.Sheets("Sheet1")
      With .Range("AA1", .Range("AA" & Rows.Count).End(xlUp))
         .Replace "*ZR*", "=XXX", xlPart, , False, , False, False
         .SpecialCells(xlFormulas, xlErrors).Offset(-1).Value = "=XXX"
         .SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
      End With
   End With
   wb.Close True
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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