ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete row programmatically (https://www.excelbanter.com/excel-programming/308821-delete-row-programmatically.html)

Pat

delete row programmatically
 
Is it possible to delete a row on a sheet programmatically? If say data in
A4, A7, A37 contained the word "delete" could it be possible for code to
find the word "delete" colA and then proceed to delete the entire row?

Any thoughts about whether this is possible?
Pat



Frank Kabel

delete row programmatically
 
Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, 1).Value = "delete" then
rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub

also have a look at:
http://www.xldynamic.com/source/xld.Deleting.html

--
Regards
Frank Kabel
Frankfurt, Germany


Pat wrote:
Is it possible to delete a row on a sheet programmatically? If say
data in A4, A7, A37 contained the word "delete" could it be possible
for code to find the word "delete" colA and then proceed to delete
the entire row?

Any thoughts about whether this is possible?
Pat


Andoni[_24_]

delete row programmatically
 
Sub TryThis()
Dim X As Long
Dim Y As Long
Y = Range("A65536").End(xlUp).Row
'y= find the last non empty cell in column A
For X = Y To 1 Step -1
'Lcase gets the lower case of the word
If lcase(Cells(X, 1).Value) = "delete" Then
Rows(X).Delete
End If
Next

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:14 AM.

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