evaluating text cell contents

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a large number of cells with nothing but text in them. I want to
evaluate the first few words in each and then create a macro to move the
contents of that cell to a new column depending on the cell's contents. Any
creative ideas out there? I am using Excel 2000.
 
Make a list on a new worksheet of those words/phrases.

Put them in A1:Axx.

Then loop through your cells looking for those words/phrases. If you find
it/them, then move the contents and go to the next cell.

dim ListWks as worksheet
dim wks as worksheet
dim myRng as range
dim myCell as range
dim myListRng as range
dim myListCell as range

set wks = worksheets("sheet1")
set listwks = worksheets("list")

with wks
set myrng = .range("a1",.cells(.rows.count,"A").end(xlup))
end with

with listwks
set mylistrng = .range("a1",.cells(.rows.count,"A").end(xlup))
end with


for each mycell in myrng.cells
for each mylistcell in mylistrng.cells
if application.countif(mycell.value,"*" & mylistcell.value & "*") > 0 then
mycell.offset(0,1).value = mycell.value
exit for 'already moved it
end if
next mylistcell
next mycell

=======
Watch out for typos--I didn't test this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top