loribear180
New Member
- Joined
- Apr 13, 2021
- Messages
- 29
- Office Version
- 2016
- Platform
- Windows
Hello all,
Excel newbie here ? I learned about formatting a spreadsheet with If Statements, however, the way I learned them is by inputting the formula into the each specific field.
A colleague shared a spreadsheet with macros, however, I'm trying to fix a certain one. Currently, if there is no input my field changes to '0'. How do I enter an If Statement into the actual code? I think I attached the code correctly below:
Excel newbie here ? I learned about formatting a spreadsheet with If Statements, however, the way I learned them is by inputting the formula into the each specific field.
A colleague shared a spreadsheet with macros, however, I'm trying to fix a certain one. Currently, if there is no input my field changes to '0'. How do I enter an If Statement into the actual code? I think I attached the code correctly below:
VBA Code:
'Converts Formulas to values for on each tab
Sub ConvertFormulasToValuesAllWorksheets()
Dim ws As Worksheet, rng As Range
For Each ws In ActiveWorkbook.Worksheets
For Each rng In ws.UsedRange
If rng.HasFormula Then
rng.Formula = rng.Value
End If
Next rng
Next ws
End Sub