View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Aria Aria is offline
external usenet poster
 
Posts: 5
Default Find & Replace Dash

Hi! Thanks for your response.
I actually only want it to cover column C but the macro as it is runs
through other columns. For instance, my actual worksheet has 19 columns and
the macro is going through 14 of them doing the replace.

"Patrick Molloy" wrote:

you need to specify column A if you want your serach to cover it too...

Columns("A:C").Replace What:="-", Replacement:="REP", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False


"aria" wrote:

For this example, "I" in the macro would be "C".

"aria" wrote:

I have a macro that finds and replaces "-" with text ("REP") in a particular
column (in this example, C). My worksheet looks like this:
A B C
abc 123 abc
- 321 -
abc 456 -
a-c 654 -

The macro works fine except for rows that happen to also have a dash in
column A. Maybe my macro isn't specifying column C exactly? I used the
Record Macro option...
Sub ReplaceDash()
Columns("I:I").Select
Range("I7").Activate
Selection.Replace What:="-", Replacement:="REP", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

Could someone please shed some light? Thanks in advance!