why does cell.replace work with byrows and not with bycolumns

C

chris12345

Hi,

I have a macro where I want to replace a certain string with another
string. However, when I put in the macro
Cells.Replace What:="(1 markets)", Replacement:="(1 market)", LookAt:=
_
xlPart, SearchOrder:=xlByColumns, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
it does nothing, but if I change SearchOrder:=xlByColumns to
SearchOrder:=xlByRows, then it works fine.

Can anyone explain why? If it helps, the cells in which the strings to
be replaced can be found are all in 3 cells merged together, with the
string in the left most of the 3 cells (all 3 cells are on the same
row).

Thanks!
 
D

Dave Peterson

Merged cells are a pain.

There are somethings that work with merged cells and some (lots???) of things
that don't.

You may want to consider yourself lucky since you do have an alternative.

ps. I tested in xl2003. But each version of excel seems to treat merged cells
a little better. Maybe it works in xl2007 or will work in xl2010????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top