Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find & Replace Dash

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find & Replace Dash

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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Find & Replace Dash

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Find & Replace Dash

On Mar 24, 7:46*pm, 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!


Hi,

Do you want to replace dash in column A also?

Anant
  #5   Report Post  
Posted to microsoft.public.excel.programming
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!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find & Replace Dash

What did you mean when you said the "macro works fine except for rows that
happen to also have a dash in column A"? When I run the macro, it replaces
all of the dashes in Column C no matter what is in Column A on that row,
which is what the macro is set up to do (although I'm not sure why you are
activating C7 after selecting the whole column). Perhaps if you mention
exactly what is supposed to be happening, or what is not happening the way
you expect it to be happening, that might help us in figuring out your exact
problem.

Rick


"aria" wrote in message
...
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!


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find & Replace Dash

Not on my system it doesn't. This macro (yours with the I's replaced by
C's)...

Sub ReplaceDash()
Columns("C:C").Select
Range("C7").Activate
Selection.Replace What:="-", Replacement:="REP", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

replaces only the dashes in Column C... no other column is affected.

Rick


"aria" wrote in message
...
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!


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find & Replace Dash

I found that the macro was getting thrown off by some merged cells somewhere
at the beginning of the very lengthy worksheet. After I fixed that the macro
stayed in one column instead of moving out into the others.

Thanks to everyone who took the time to respond!

"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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Comma's with Dash [email protected] Excel Worksheet Functions 3 May 5th 23 11:45 AM
Find And Replace a Dash Maverick50 Excel Discussion (Misc queries) 5 January 23rd 09 02:05 PM
Replace Comma with Dash [email protected] Excel Worksheet Functions 3 April 18th 08 10:26 AM
replace dash in a number sequence Willy Wonka Excel Worksheet Functions 1 February 14th 08 12:04 AM
Replace Error with a Dash Karen Excel Worksheet Functions 3 March 14th 06 05:33 PM


All times are GMT +1. The time now is 09:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"