VBA and Excell - really need you help
The "-" parts of your "-02-" may just be due to the date formatting rather
than what is "really" in the cell. When you select such a cell what is in
the formula bar? Whatever is up there ("/2/" for me) is what you can find
and replace on.
--
Jim
"Xaraam" wrote in message
...
| Hey!
|
| I'm kind of dummie in VBA. I usually just work with it to create macros.
| I've a important challenge now, that is: using an excel sheet with,
average,
| 20000 cells, I need to replace a part of the cell content several times
(i.e.
| if my cell is 01-02-2006, the "02" has to be replaced by "MA").
| I'm using the VB6 version and excel 2003.
|
| i've tried this code:
| sub replace()
| worksheets("book1").select
| Cells.Replace What:="-02-", Replacement:="-MA-", LookAt:=xlPart, _
| SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,_
| ReplaceFormat:=False
| end sub()
|
| the cells are formatted to date.
|
| i've just noticed that the code does work but sometimes, i.e. if i want to
| replace the content "-02-" to "-MA-", in all my attempts it just worked
once.
| But if i replace "2006" to "-MA-", it work all the time and the replace
| cells are something like this: "01/02/-MA-", from the previous:
"01-02-2006".
| Even if i replace "0" to MA on "01-02-2006" the result will be:
| "1/2/2-MA--MA-6"
|
| BUt even after all this test and puting the cells on the original values i
| try to do the "-02-" to "-MA-" replacement and nothing happens, nor even a
| error
| message.
|
| Can you help me out here?..thanks in advance.
|