Change formula to Indirect

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to change a lot of formulas to "Indirect".

Example, A1, =B1 - Need to change it to =Indirect("B1")

I have been trying find and replace;

Find =, Replace XIndirect("
This produces XIndirect("B1

How can I Find the end of formula and add, ")

Any ideas on how to add to the end of the formula or any other way of
changing a formula to indirect would be appreciated.
 
Sub change_formula()
For c = 1 To 5
For r = 1 To 10
Cells(r, c).Formula = "=indirect(""" & Right(Cells(r, c).Formula,
Len(Cells(r, c).Formula) - 1) & """)"
Next r
Next c
End Sub
 
Ian -

Thanks a lot, that is exactly what I need. However, I am getting a syntax in

Cells(r, c).Formula = "=indirect(""" & Right(Cells(r, c).Formula,
Len(Cells(r, c).Formula) - 1) & """)"

which I copied and pasted. Any ideas?
 
The text has been wordwrapped and those 2 lines should all be on one line.
 

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