Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default reading inside a text string

what I need is a sub that will read all the cells in a specified colum
and delete rows if the word "Old" in the cell anywhere.
such as big old car?

Is that possible. I have a nice sub that deletes rows according t
contents, but I don't know how to make it look between word

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default reading inside a text string

Hi
try the following for column A

Sub delete_rows()

Dim RowNdx As Long
Dim LastRow As Long

LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If InStr (Cells(RowNdx, "A").Value,Old") Then
Rows(RowNdx).Delete
End If
Next RowNdx

End Sub



--
Regards
Frank Kabel
Frankfurt, Germany

what I need is a sub that will read all the cells in a specified
column and delete rows if the word "Old" in the cell anywhere.
such as big old car?

Is that possible. I have a nice sub that deletes rows according to
contents, but I don't know how to make it look between words


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default reading inside a text string

One way:-

Just change the 1 in the 'With Cells(r, 1)' bit to whatever column number you
will be using.


Sub DeleteRowsContaining()
Dim r As Long
Dim ans As String
Dim c As Range
Dim lrow As Long

ans = InputBox("What string do you want rows to be deleted if they contain it?")
Application.ScreenUpdating = False

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For r = lrow To 1 Step -1
With Cells(r, 1)
Set c = .Find(ans, LookIn:=xlValues)
If Not c Is Nothing Then
.EntireRow.Delete
End If
End With
Next r
Application.ScreenUpdating = True

End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"ksnapp " wrote in message
...
what I need is a sub that will read all the cells in a specified column
and delete rows if the word "Old" in the cell anywhere.
such as big old car?

Is that possible. I have a nice sub that deletes rows according to
contents, but I don't know how to make it look between words


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default reading inside a text string

Sub test()
Const cColumn = 2, cSearch = "f"
Dim i As Long, lngLastRow As Long

With ActiveSheet
lngLastRow = .Cells(Rows.Count, cColumn).End(xlUp).Row

For i = lngLastRow To 1 Step -1
If InStr(1, .Cells(i, cColumn).Value, cSearch) 0 Then
.Rows(i).Delete xlShiftUp
End If
Next
End With
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"ksnapp " wrote in message
...
what I need is a sub that will read all the cells in a specified column
and delete rows if the word "Old" in the cell anywhere.
such as big old car?

Is that possible. I have a nice sub that deletes rows according to
contents, but I don't know how to make it look between words


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default reading inside a text string

Your fingers are too fast Frank - Missed that first pair of quotes round the
'Old':-

If InStr (Cells(RowNdx, "A").Value,Old") Then :-)


--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"Frank Kabel" wrote in message
...
Hi
try the following for column A

Sub delete_rows()

Dim RowNdx As Long
Dim LastRow As Long

LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If InStr (Cells(RowNdx, "A").Value,Old") Then
Rows(RowNdx).Delete
End If
Next RowNdx

End Sub



--
Regards
Frank Kabel
Frankfurt, Germany

what I need is a sub that will read all the cells in a specified
column and delete rows if the word "Old" in the cell anywhere.
such as big old car?

Is that possible. I have a nice sub that deletes rows according to
contents, but I don't know how to make it look between words


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004


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
Searching for a string of text inside a column Steve W. Excel Worksheet Functions 5 March 5th 09 04:52 PM
Creating a text string by reading content in multiple cells smaruzzi Excel Worksheet Functions 3 February 8th 07 05:12 PM
Visual Basic 6 - String Reading V Govindan Excel Discussion (Misc queries) 2 December 7th 06 03:56 PM
Need macro to insert text string while inside cell (formula) BrianB Excel Discussion (Misc queries) 0 May 31st 05 03:18 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM


All times are GMT +1. The time now is 02:02 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"