How To Change the formula in the cells in a range to values using VBA?
Tags: tochangetheformulain, vbamacros
Published: 2021-10-20 08:08:06

---
title: How To Change the formula in the cells in a range to values using VBA?
published: true
date: 2021-10-19 10:05:44 UTC
tags: ToChangeTheFormulaIn,VBAMacros
canonical_url: https://geekexcel.com/how-to-change-the-formula-in-the-cells-in-a-range-to-values-using-vba/
---

In this article, you will learn how to  **change the formula in the cells in a range to values using VBA**  in Microsoft Excel. Let’s see them below!! Get the official version of  **MS Excel**  from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Example

- Firstly, you need to  **create a sample data**  in Excel Spreadsheet.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Sample-data-32.png)<figcaption>Sample data</figcaption>

- In the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to  **copy and paste the code**  given below.

```
Option Explicit
Sub ChangingFormulasToValue()
'Declaring variables
Dim SourceRng As Range
'Specify all cells in the active sheet as range
Set SourceRng = Range("A1", Range("A1").SpecialCells(xlCellTypeLastCell))
'Assigning only value of the cell skipping formula of the cell
SourceRng.Value = SourceRng.Value
End Sub

```

- After that, you need to  **save the code**  by selecting it and then  **close the window**.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Save-the-Code-59.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- Then, you need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Run-the-Code-50.png)<figcaption>Run the Code</figcaption>

- Finally, after running the macro, you can see **formula in H18 cell** is converted to **value ** as given below in Excel.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Output-32.png)<figcaption>Output</figcaption>

## Verdict

We hope that this article gives you guidelines on how to  **change the formula in the cells in a range to values using VBA**  in Microsoft Excel. ** ** Please leave a comment in case of any  **queries,**  and don’t forget to mention your valuable  **suggestions**  as well. Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Keep Reading:**

- **[How to Change the Date Format in Excel Office 365? ~ Complete Guide!!](https://geekexcel.com/change-date-format-in-excel/)**
- **[Change the Time Format in Excel Office 365 ~ Useful Guide!!](https://geekexcel.com/change-the-time-format-in-excel/)**
- **[Excel Formulas to Find the Same Date in Next Year ~ Simple Guide!!](https://geekexcel.com/excel-formulas-to-find-the-same-date-in-next-year/)**
- **[How to make Gantt charts by weeks in Excel 365?](https://geekexcel.com/how-to-make-gantt-charts-by-weeks-in-excel-365/)**
- **[How To Mail every Worksheet with address in cell A1 using VBA in Excel?](https://geekexcel.com/how-to-mail-every-worksheet-with-address-in-cell-a1-using-vba-in-excel/)**