Good morning all!!
I'm trying to loop through all the worksheets in a workbook changing all the formulas to values. This works for 93 out of the 94 sheets in the workbook, but for some reason I am getting a runtime error '1004' application defined or object defined error on the 94th worksheet. I have no clue why. My code looks like this:
Sub swapValues()
Dim i As Long
Dim ws_num As Long
Dim starting_ws As Worksheet
Set starting_ws = ActiveSheet
ws_num = ThisWorkbook.Worksheets.Count
For i = 1 To ws_num
ThisWorkbook.Worksheets(i).Activate
With ActiveSheet.Range("A1:CZ300")
.Value = .Value
End With
Next i
starting_ws.Activate
End Sub
It does get halfway through the sheet turning formulas to values before stopping. When I get the error, it highlights the line .Value = .Value. Any help would be appreciated.
Dome
Bookmarks