View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charlie Charlie is offline
external usenet poster
 
Posts: 703
Default Replace only "A*" by an other text

Dim Cell As Range

For Each Cell In Range("C:C")
If Left(Cell, 1) = "A" Then Cell = "A-" & Mid(Cell, 2)
Next Cell


"Alex St-Pierre" wrote:

Hello,
I have a column which contains text like A, A*,AI,AT,D, etc.
I would like to replace only the A* value by A-* using vba (because excel
consider the A* as any text beginning by A). My formula below doesn't work.
Any idea?
Thanks!

Cells.Replace What:="A*", Replacement:="A-*", LookAt:=xlWhole, _
SearchOrder:=xlByColumns, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
--
Alex St-Pierre