View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Finding values within text and substituting with alternate values.

the macro recorder is your friend
Sub Macro5()
'
' Macro5 Macro
' Macro recorded 1/23/2006 by Don Guillett
'

'
Range("C2:C11").Select
Selection.Replace What:="aa", Replacement:="bb", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub


--
Don Guillett
SalesAid Software

"Bhupinder Rayat" wrote in
message ...
Hi All,

I have a table with two columns, column A contains old values and column
B
contains new values.

I am trying to create a program, where I paste a piece of text into a
separate worksheet, which contains old values (can be randomly within the
text, in any cell). I want excel the search through the text and find any
old values from column A and replace them with new values, i.e. if value
in
A7 is found in text, then replace with its corresponding new value from
B7.

Also, I don't want the code to fall over when no values are found, and for
it to move to the next value in the table, i.e. old value in A5 returns no
match in text, so move onto old value in A6 and try to find a match.

Is this possible to achieve? Any help will be much appreciated.


Kind Regards,

Bhupinder