Looking for ways to change font within formula in Excel? Then, this is the right place for you. By changing the font within the formula, you may make it easily visible and also change its color, font style, making it bold or italic. Here, you will find 3 ways to change font within formula in Excel.
How to Change Font Within Formula in Excel: 3 Easy Ways
Now, we will show you 3 methods to change the font in the formula bar and also change the font within the formula using VBA in Excel.
1. Use Excel Options to Change Font Within Formula in Excel
Sometimes, you may want to show a formula in the formula bar. However, you cannot change its font size by zooming in or out. In that case, you may use the Excel Options dialog box.
Here, we have a dataset containing the Product list and the Sales value of a shop. We used the SUM function to calculate the Total Sales of that shop and showed the formula in the formula bar. Now, we will show you how you can change the font size in the formula bar.
Follow the steps given below to do that for your dataset.
- Firstly, click on File.
- Then, click on Options.
- Now, the Excel Options toolbox will open.
- Next, from the General option, change the font size according to your wish.
- Here, we selected 16 as Font size.
- After that, click on OK.
- Afterward, a Msgbox will open to inform you to reopen the Excel file.
- So, click on OK and reopen your file to see the changes.
- Finally, you will see that the font size in the formula bar has been changed.
2. Manually Changing Font Within Formula Bar
Now, suppose you want to change the font of some particular text or number in a cell. You can do this by selecting that cell and then manually changing fonts within the formula bar in Excel.
Here, in our dataset, we have a statement in cell B5. Now, we will change the font of the text “James” and date “1st February 2023” manually within the formula bar.
Here are the steps.
- Firstly, select cell B5 and go to the formula bar.
- Then, select the text “James”.
- After that, change the font color, style, and size according to your wish.
- Here, we will set Abadi as Font, 16 as Font Size, and Red as Font Color, and click on Bold to bold the text.
- Next, to change the font of the date, we will select “1st February 2023”.
- Then, we will set 16 as Font Size and click on Bold and Italic to change its font.
- Thus, you can manually change the font within formula bar in Excel.
3. Change Font Within Formula Using VBA in Excel
In the last method, we will use VBA to change the font color within the formula under specific conditions in Excel. Here, we have a dataset containing the Score of some students and the Highest Score of them. Now, suppose we want to identify the highest score with a different font color and add an extra 2 marks with it. We can do it easily by using a formula and VBA.
- In the beginning, press Alt + F11 on your keyboard or go to the tab Developer >> click on Visual Basic to open Visual Basic Editor.
- Then, from the menu bar, click on Insert >> select Module.
- Next, copy the following code and paste it into the code window.
Function Font_Color(M1 As Double, M2 As Double) As Boolean
If M1 >= M2 Then
Application.Caller.Font.ColorIndex = 3
Application.Caller.Font.ColorIndex = xlAutomatic
- To start with, we created a VBA Function named Font_Color and took M1 as M2 as variables where we set both of them as Double.
- After that, we checked If M1>=M2, then the Font Color will change or otherwise it will remain the same.
- Next, click on the Save button to save the code.
- Afterward, insert the following formula in cell C7 and press Enter.
- Then, drag right the Fill Handle tool to auto fill the formula for the rest of the cells.
- Finally, you will get the Final Score of the students and the font color of the highest value has been changed according to the formula.
🔎 How Does the Formula Work?
- To start with, we used the IF function to check if the value of cell C5 is greater than or equal to cell C6, then it will return the value of cell C6 + 2 or else it will return the value of cell C5.
- Then, we used the Font_Color function that we created using VBA to change the font color.
In the article, you will find an Excel workbook like the image given below to practice on your own.
Download Practice Workbook
You can download the workbook to practice yourself.
So, in this article, we have shown you 3 ways to change font within the formula in Excel. I hope you found this article interesting and helpful. If something seems difficult to understand, please leave a comment. Please let us know if there are any more alternatives that we may have missed. Thank you!
- How to Lock Font in Excel
- Increase Font Size for Printing in Excel
- How to Increase Font Size Using Keyboard in Excel
- [Fixed!] Excel Default Font Is Not Changing
- [Solved!] Unable to Change Font Color in Excel
- How to Change Font in Excel for All Sheets
- How to Change Font in Excel to All Caps
- How to Change Font Style in Excel