Macro change formulas to values

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
346
Office Version
  1. 2019
Platform
  1. Windows
Hi i have a workbook with sheets names 1,2,3,4,5,67,8,9,10

Would anyone have a macro that would change the cells B2 to C10 and G2 to G20 from formulas into values ?
Thanks
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,384
Office Version
  1. 2019
Platform
  1. Windows
Try,

VBA Code:
Sub MakeValue()
    Dim i As Integer
    Dim cell As Range
    For i = 1 To 10
     For Each cell In Worksheets(CStr(i)).Range("B2:C10,G2:G20").Cells
        cell.Value = cell.Value
     Next cell
    Next i
End Sub

Dave
 

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
346
Office Version
  1. 2019
Platform
  1. Windows
Try,

VBA Code:
Sub MakeValue()
    Dim i As Integer
    Dim cell As Range
    For i = 1 To 10
     For Each cell In Worksheets(CStr(i)).Range("B2:C10,G2:G20").Cells
        cell.Value = cell.Value
     Next cell
    Next i
End Sub

Dave
Thanks alot, thats perfect
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,384
Office Version
  1. 2019
Platform
  1. Windows
Glad it worked

untested but another approach maybe

VBA Code:
Sub MakeValue()
    Dim i As Integer
    Dim Areas As Range
    For i = 1 To 10
     For Each Area In Worksheets(CStr(i)).Range("B2:C10,G2:G20").Areas
        Area.Value = Area.Value
     Next Area
    Next i
End Sub

Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,123,156
Messages
5,600,040
Members
414,357
Latest member
Gemma_R

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
Top