Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find a specific string in a cell

I would like to search all the cells that are not empty in column E for
the words Account and New. If the cell does not have either of those
words in it, I would like to delete that entire row, go to the next
cell in column E and repeat this action until I arrive at an empty
cell.

Please help

LP

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find a specific string in a cell


sub n()
dim c as range
set rng = Range("e1",Cells(rows.count,"e").end(xlUp))
for each c in rng
if c.value="Account" or c.value="New" then
c.entirerow.delete
end if
next
end sub


hth
myle

--
Myle
-----------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...fo&userid=2874
View this thread: http://www.excelforum.com/showthread.php?threadid=57418

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find a specific string in a cell

Hey Myles. Thanks for the reply. I attempted that but it didn't exactly
work. I believe that I am leaving out some pertinent information. The
cells that I searching do not only have the words Account or New in
them. They are a part of a longer string where those words are just the
beginning of that string. For example: AccountSalary, or NewMachine.
What I want to do is delete the rows of associated with any cell in
column E that do not have the words Account or New as a part of the
value in the cell. Thank you for you help.

Myles wrote:
sub n()
dim c as range
set rng = Range("e1",Cells(rows.count,"e").end(xlUp))
for each c in rng
if c.value="Account" or c.value="New" then
c.entirerow.delete
end if
next
end sub


hth
myles


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=574183


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find a specific string in a cell


Sub sWords()
Range("E1").Select

Do While Len(ActiveCell.Value) < 0
str1 = InStr(1, ActiveCell.Value, "New")
str2 = InStr(1, ActiveCell.Value, "Account")
If str1 = 1 Or str2 = 1 Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop

End Sub

That should do it.

Cheers
Jo

--
LFCFa
-----------------------------------------------------------------------
LFCFan's Profile: http://www.excelforum.com/member.php...fo&userid=3748
View this thread: http://www.excelforum.com/showthread.php?threadid=57418

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
Find specific info within a text string using VBA laavista Excel Discussion (Misc queries) 2 May 20th 09 06:37 PM
Find a specific formatted string in a cell KCK Excel Worksheet Functions 1 April 16th 08 09:16 PM
Find specific value in a string Lost in Microbiology Excel Discussion (Misc queries) 8 May 16th 07 09:58 AM
Find specific text in a string Samuel[_5_] Excel Programming 4 February 22nd 05 10:27 PM
Find specific text in a string Kilcup Excel Programming 5 June 10th 04 04:29 PM


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

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

About Us

"It's about Microsoft Excel"