X
Xaraam
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.
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.