Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Excel Macro to find instances of a word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cmorecroft@teleflexmedical.com - 05 Apr 2007 13:18 GMT
I'm in the process of learning VBA and am having some troubles writing
an excel macro to find all instances of a word (usually in conjunction
with other words) and delete the row containing it

essentially I'd like row 5 below to do the following:

If Cell contains word *foo* OR *baz* then

such that it would find individual instances of foo and baz but also
foobar

Although overall a rather large macro, the code surrounding

1    Cells.Sort Key1:=Range("C1")
2
3    totalrows = ActiveSheet.UsedRange.Rows.Count
4        For Row = totalrows To 2 Step -1
5            IF CELLS(ROW, 3).VALUE = **FOO** OR CELL(ROW, 3).VALUE=
**BAZ** Then
6                Rows(Row).Delete
7        End If
8    Next Row

Thanks!

--Chris
Dave Peterson - 05 Apr 2007 13:30 GMT
Look in VBA's help for Like (and ucase).

IF ucase(CELLS(ROW, 3).VALUE) like **FOO** _
OR ucase(CELL(ROW, 3).VALUE) like **BAZ** Then

You may want to look at VBA's help for InStr, too.

> I'm in the process of learning VBA and am having some troubles writing
> an excel macro to find all instances of a word (usually in conjunction
[quoted text clipped - 22 lines]
>
> --Chris

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.