ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace only "A*" by an other text (https://www.excelbanter.com/excel-programming/354206-replace-only-%2A-other-text.html)

Alex St-Pierre

Replace only "A*" by an other text
 
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

Charlie

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


Alex St-Pierre

Replace only "A*" by an other text
 
Do you know why the value is not replaced in excel ?
Cell = "ABC" does't work
--
Alex St-Pierre


"Charlie" wrote:

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


Alex St-Pierre

Replace only "A*" by an other text
 
this is working:
For j = 1 To 65536
If Left(Cells(j, 3), 2) = "A*" Then Cells(j, 3) = "A-*"
Next j

--
Alex St-Pierre


"Charlie" wrote:

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


kounoike[_2_]

Replace only "A*" by an other text
 
something like this?

Cells.SpecialCells(xlCellTypeConstants).Select
For Each rng In Selection
If rng Like "A[*]*" Then
rng.Value = Replace(rng, "A*", "A_*")
End If
Next

keizi

"Alex St-Pierre" wrote in message
...
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




All times are GMT +1. The time now is 10:38 AM.

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