Changing values in formulas with VBA

  • Thread starter Thread starter mirca_00
  • Start date Start date
M

mirca_00

Hi!

I would need some help with this case.

I am trying to replace "7;faux" for "8;faux" in an excel formula. I
have this code, but it only searchs in the cells, not the formulas.

Range("H258:H390").Select
Selection.Replace What:="7;faux", Replacement:="8;faux", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Could anyone let me know how to made it search in the formulas instead
of the cells?

Thanks alot!

Melanie
 
Replace does not look in formulas. Use search to find cells with
formulas (LookIn:xlFormulas) and then use the Replace function on the
formula of the found objects.
 
first there is no lookin argument for the replace command.

expression.Replace(What, Replacement, LookAt, SearchOrder, MatchCase,
MatchByte)

second, replace can only look at formulas. How would it replace the
displayed value of a formula. It can't. Constants in a cell are also
considered to be formulas.

So if you code isn't working it must have something to do with the string
you are trying to replace rather than a missing argument to the
function/method.
 

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

Back
Top