Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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 .
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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 .

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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 .



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro analyses Cell . If text found , delets entire row

Many thanks guys

Both macro work !


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro that analyses data from 3 columns and puts result in 4th andrei Excel Programming 2 September 30th 09 09:18 AM
Macro that delets all cells containg ALL words in bold andrei Excel Programming 3 September 29th 09 03:57 PM
macro which delets cell if the cell above has the same keyword andrei Excel Programming 2 September 29th 09 07:46 AM
Macro which searches for a character . When found delets what's be andrei Excel Programming 4 September 28th 09 06:09 PM
Highlight found text string in cell? Ed[_18_] Excel Programming 4 June 4th 04 03:07 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"