DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Print Formula Syntax using VBA in Microsoft Excel?

In this article, you will learn how to print the formula syntax using VBA in Microsoft Excel. Let’s get them below!! Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel

Use Show Formulas option

  • Firstly, you need to create a sample values and some are extracted using formula and some are not.

Sample data

  • 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
Select Visual Basic

  • Now, you have to go to Formulas and click on Show formulas under Formula Auditing.

Click on Show formulas

  • After that, you need to click the Show Formula option to view all formulas of the sheet or use the shortcut Ctrl + ` (tilde) from the keyboard.
  • Finally, this option lets you view all Excel Formulas used in the worksheet instead of the results.

Output

To view the Formula of a particular cell

  • Firstly, you have to use the single quote mark in front of the formula and let you show only formulas, not the result of the cell.
  • Then, you need to use the formula as given below.


=TEXT(A2, "m")

Result of the cell

  • Now, you have to view formulas on B2 & C3 cell and just apply one single quote mark in front of the formula.
  • After that, you need to use the formula as given below.


'=TEXT(A2, "m")

Apply one single quote mark

  • Finally, you have to apply the same in C3 cell to view Excel formula instead of results.

Apply the same in C3 cell

NOTES:

  • Each Formula in Excel starts with ( = ) sign.
  • Sometimes there exist a curly brace in the start of formula, which is an array formula and called using the Ctrl + Shift + Enter. Do not put curly braces manually.
  • Text values and characters are always given using quotes or using cell reference.
  • Numerical values can be given directly or using the cell reference.
  • Array can be given using the array reference or using named ranges.

Summary

We hope that this article gives you guidelines on how to print the formula syntax 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!! *Read more on Excel Formulas *!!

Read Ahead:

Top comments (0)