![]() |
Macro analyses Cell . If text found , delets entire row
I have a table with many columns and rows . Tha Macro should search if cells
from C column contain text . If yes , it delets entire row . |
Macro analyses Cell . If text found , delets entire row
Something like this:
Sub rowkiller() Dim s As String, n As Long, i As Long s = "text" n = Cells(Rows.Count, 3).End(xlUp).Row For i = n To 1 Step -1 If InStr(Cells(i, 3).Value, s) 0 Then Rows(i).Delete End If Next End Sub -- Gary''s Student - gsnu200906 "andrei" wrote: I have a table with many columns and rows . Tha Macro should search if cells from C column contain text . If yes , it delets entire row . |
Macro analyses Cell . If text found , delets entire row
I didn't take your "text" to mean the word "text". I think you meant any
text not including a numeric entry. The following macro will do what you want. HTH Otto Sub DelCText() Dim rColC As Range Dim c As Long Set rColC = Range("C2", Range("C" & Rows.Count).End(xlUp)) For c = rColC(rColC.Count) To 1 Step -1 If rColC(c) < "" And _ Not IsNumeric(rColC(c)) Then _ rColC(c).EntireRow.Delete Next c End Sub "andrei" wrote in message ... I have a table with many columns and rows . Tha Macro should search if cells from C column contain text . If yes , it delets entire row . |
Macro analyses Cell . If text found , delets entire row
Yep , i meant any text not including numeric entry
The macro gives a type mismatch for : For c = rColC(rColC.Count) To 1 Step -1 @Gary''s Student I tried your macro , also . But it nothing happens "Otto Moehrbach" wrote: I didn't take your "text" to mean the word "text". I think you meant any text not including a numeric entry. The following macro will do what you want. HTH Otto Sub DelCText() Dim rColC As Range Dim c As Long Set rColC = Range("C2", Range("C" & Rows.Count).End(xlUp)) For c = rColC(rColC.Count) To 1 Step -1 If rColC(c) < "" And _ Not IsNumeric(rColC(c)) Then _ rColC(c).EntireRow.Delete Next c End Sub |
Macro analyses Cell . If text found , delets entire row
Yes, my mistake. Change it to: Otto
For c = rColC.Count To 1 Step -1 "andrei" wrote in message ... Yep , i meant any text not including numeric entry The macro gives a type mismatch for : For c = rColC(rColC.Count) To 1 Step -1 @Gary''s Student I tried your macro , also . But it nothing happens "Otto Moehrbach" wrote: I didn't take your "text" to mean the word "text". I think you meant any text not including a numeric entry. The following macro will do what you want. HTH Otto Sub DelCText() Dim rColC As Range Dim c As Long Set rColC = Range("C2", Range("C" & Rows.Count).End(xlUp)) For c = rColC(rColC.Count) To 1 Step -1 If rColC(c) < "" And _ Not IsNumeric(rColC(c)) Then _ rColC(c).EntireRow.Delete Next c End Sub |
Macro analyses Cell . If text found , delets entire row
This version removes rows with any text in column C:
Sub rowkiller2() Dim n As Long, i As Long n = Cells(Rows.Count, 3).End(xlUp).Row For i = n To 1 Step -1 If IsNumeric(Cells(i, 3).Value) Then Else Rows(i).Delete End If Next End Sub -- Gary''s Student - gsnu200906 "andrei" wrote: Yep , i meant any text not including numeric entry The macro gives a type mismatch for : For c = rColC(rColC.Count) To 1 Step -1 @Gary''s Student I tried your macro , also . But it nothing happens "Otto Moehrbach" wrote: I didn't take your "text" to mean the word "text". I think you meant any text not including a numeric entry. The following macro will do what you want. HTH Otto Sub DelCText() Dim rColC As Range Dim c As Long Set rColC = Range("C2", Range("C" & Rows.Count).End(xlUp)) For c = rColC(rColC.Count) To 1 Step -1 If rColC(c) < "" And _ Not IsNumeric(rColC(c)) Then _ rColC(c).EntireRow.Delete Next c End Sub |
Macro analyses Cell . If text found , delets entire row
Many thanks guys
Both macro work ! |
All times are GMT +1. The time now is 03:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com