ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Rows (https://www.excelbanter.com/excel-programming/277434-re-delete-rows.html)

Cole[_2_]

Delete Rows
 
Sub deleteRow()
Range("a1").Select
Do Until ActiveCell.Address = "$A$10" 'to whichever cell is ending
If ActiveCell.Value = "bo501" Then
Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub
"dayton" wrote in message
...
I need my macro to delete rows that start with specfic data, not clear the
row but delete. If row begins with text "bo501" delete.
T.I.A.
Dayton







dayton

Delete Rows
 
How would I modify this to delete rows where the text in the rows begins
with "bo501" followed my more text. I tried using "bo501*".
Thanks



"Cole" wrote in message
...
Sub deleteRow()
Range("a1").Select
Do Until ActiveCell.Address = "$A$10" 'to whichever cell is ending
If ActiveCell.Value = "bo501" Then
Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub
"dayton" wrote in message
...
I need my macro to delete rows that start with specfic data, not clear

the
row but delete. If row begins with text "bo501" delete.
T.I.A.
Dayton









Trevor Shuttleworth

Delete Rows
 
Dayton

try this:

Sub DeleteRow2()
Dim LastRow As Long
Dim i As Long
LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 1 Step -1
If Range("A" & i).Value Like "bo501*" Then
Range("A" & i).EntireRow.Delete
End If
Next 'i
End Sub

Regards

Trevor


"dayton" wrote in message
...
How would I modify this to delete rows where the text in the rows begins
with "bo501" followed my more text. I tried using "bo501*".
Thanks



"Cole" wrote in message
...
Sub deleteRow()
Range("a1").Select
Do Until ActiveCell.Address = "$A$10" 'to whichever cell is

ending
If ActiveCell.Value = "bo501" Then
Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub
"dayton" wrote in message
...
I need my macro to delete rows that start with specfic data, not clear

the
row but delete. If row begins with text "bo501" delete.
T.I.A.
Dayton












All times are GMT +1. The time now is 06:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com