View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Search and Replace columns using Case?

try this. Modify to suit.
Sub replaceem()
For Each c In Selection
Select Case UCase(c)
Case "DOG": c.Value = "Cat"
Case "CAT": c.Value = "Mouse"
End Select
Next c
End Sub
--
Don Guillett
SalesAid Software

"john_t_h " wrote in message
...
I want to run a macro that will search through the rows of a column and
if the value in the cell = a certain value then replace it with
another. I also want to search another column and and if the value in
the cell = a certain value then insert another value in the next column
(same row)

while Column A does not = 0
search column B
Case
Cell = dog
then replace with Cat

Cell = Rat
then replace with Mouse

and so on for many many entries (about 300)

Cell = (empty cell)
then continue to next row

search column C
Case

Cell = spot
then insert into column D - 1

Cell = ralf
then insert into column D - 2

Cell = (empty cell)
then insert into column D - 0

and so on........

I don't know VBA very well so I'm not too sure how to write this, can
anyone help.

Thanks
John


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