ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   evaluating text cell contents (https://www.excelbanter.com/excel-discussion-misc-queries/62879-evaluating-text-cell-contents.html)

Dave B

evaluating text cell contents
 
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.


Dave Peterson

evaluating text cell contents
 
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.


Dave B wrote:

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.


--

Dave Peterson


All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com