![]() |
Ignore other values
The following code delete rows where colA contains the word "delete"
I need the code to ignore any other values in colA as the code fails on this aspect. Private Sub DeleteRows_Click() 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 X End Sub Anyone familiar with this code? Thanks Pat |
Ignore other values
Pat
in what way does it fail ? Works for me assuming just text in the cells. What do you have in the cells that the code fails on ? Regards Trevor "Pat" wrote in message ... The following code delete rows where colA contains the word "delete" I need the code to ignore any other values in colA as the code fails on this aspect. Private Sub DeleteRows_Click() 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 X End Sub Anyone familiar with this code? Thanks Pat |
Ignore other values
Hi Trevor,
I tested the code again and it works fine, I don't know what could have happened the first time around. Many thanks for supplying the code. Pat "Trevor Shuttleworth" wrote in message ... Pat in what way does it fail ? Works for me assuming just text in the cells. What do you have in the cells that the code fails on ? Regards Trevor "Pat" wrote in message ... The following code delete rows where colA contains the word "delete" I need the code to ignore any other values in colA as the code fails on this aspect. Private Sub DeleteRows_Click() 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 X End Sub Anyone familiar with this code? Thanks Pat |
All times are GMT +1. The time now is 03:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com