0

I'm pretty new with Excel VBA, so excuse me, if this question is simple :) I've spent half a day trying to google some simple and elegant way to solve my little question, but haven't succeeded yet.

The problem: I need to go through every cell with formula on the sheet and change the formula in some way (doesn't matter how).

So, what is the most efficient way to do so?

By now, I wrote some code lines that work with UsedRange, but they work incorrectly, because I haven't figured out how to identify the first cell in the UsedRange

Many thanks in advance

Regards, PG

  • 1- Post your code, 2- What exactly is the problem - why do you need the first cell if you have the `UsedRange` ? If you want to iterate over the whole `usedRange`, [this will help you](http://stackoverflow.com/questions/73785/how-to-iterate-through-all-the-cells-in-excel-vba-or-vsto-2005). – Alon Adler Sep 10 '16 at 14:30
  • I read on MSDN, that UsedRange is read-only. – PG_Develop Sep 11 '16 at 10:44
  • Checked now, whether I can actually change the cells in usedRange. Thanks a lot for your help :) – PG_Develop Sep 11 '16 at 10:45

1 Answers1

2
Sub main()
    Dim cell As Range

    For each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
        ' do what you need with cell
    Next cell
End Sub
user3598756
  • 28,893
  • 4
  • 18
  • 28