Hi there.
I've been working on some code, that among other things, is to convert all content to values (i.e. formulas and references). This is designed to run against multiple files in a single folder, with some of the files rather complex.
This is giving me some trouble, particularly with complex files containing a lot of sheets.
Here's my first attempt, which does work, but takes a very long time to run:
As you can see, this code uses the clipboard, which is highly inefficient. I need a better way.
I attempted to revise this with code that will bypass the clipboard, but it errors out:
This gives me a 1004 error ("Application-defined or object-defined error").
Any suggestions would be most appreciated.
Thanks!
I've been working on some code, that among other things, is to convert all content to values (i.e. formulas and references). This is designed to run against multiple files in a single folder, with some of the files rather complex.
This is giving me some trouble, particularly with complex files containing a lot of sheets.
Here's my first attempt, which does work, but takes a very long time to run:
Code:
Sub ConvertAllFormulaeToValues()
Dim WSheet As Worksheet
For Each WSheet In ActiveWorkbook.Worksheets
WSheet.Select
With WSheet.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Next WSheet
End Sub
As you can see, this code uses the clipboard, which is highly inefficient. I need a better way.
I attempted to revise this with code that will bypass the clipboard, but it errors out:
Code:
Sub ConvertAllFormulaeToValues()
Dim WSheet As Worksheet
For Each WSheet In ActiveWorkbook.Worksheets
WSheet.Select
With WSheet.UsedRange
.Value = .Value 'This method bypasses the clipboard, making things much more efficient.
End With
Application.CutCopyMode = False
Next WSheet
End Sub
Any suggestions would be most appreciated.
Thanks!