Replacing formulas in specific range across several worksheets (except four) with values

Julmust Jaeger

New Member
Joined
Jul 20, 2022
Messages
20
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am looking to replace formulas in specific range across several worksheets (except four) with values (to speed up loading and so on).

Basically across several worksheets I generate (so hard to predetermine a list), I need to replace a bunch of formulas in A1:C310 with values (goes super slow otherwise).

I have tried the follow (and similar codes but I keep getting a memory error).

Any help would be much appreciated!

VBA Code:
Sub ConvertFormulsToValues_Test()

    If ActiveWorkbook Is Nothing Then Exit Sub

    Dim targetAddress As String
    targetAddress = "A1:A310, B1:B310, C1:C310" 'change as desired
    
    Dim currentWorksheet As Worksheet
    For Each currentWorksheet In ActiveWorkbook.Worksheets
        If (currentWorksheet.Name <> "Company_List") And (currentWorksheet.Name <> "2019") And (currentWorksheet.Name <> "Temp") And (currentWorksheet.Name <> "Reference") Then
            With currentWorksheet.Range(targetAddress)
                .Value = .Value
            End With
        End If
    Next currentWorksheet
    
    MsgBox "Completed!", vbExclamation
    
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
It ranges based on the particular company (a first step is I split up a big dataset of 100+ companies into several individual workbooks).

Some of these workbooks have as few as 1-2 worksheets and some have as many as 31 (lol).

Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,541
Messages
6,125,413
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top