stmoritz

asked on

# Excel VBA to add + 1 to cell value only if not empty and not a formula

The following code adds 1 to every cell in defined range that has a numeric value. However it also overwrites values that are the result of formulas. It should only overwrite where the cell is a value and non empty but not when there's a formula.

Can I change it like this perhaps:

If IsNumeric(MyCell) And Not IsEmpty(MyCell) And Not IsFormula(MyCell) Then

Can I change it like this perhaps:

If IsNumeric(MyCell) And Not IsEmpty(MyCell) And Not IsFormula(MyCell) Then

```
For Each MyCell In Range("TrkLength")
If IsNumeric(MyCell) And Not IsEmpty(MyCell) Then
MyCell.Value = MyCell.Value + 1
'MyCell.NumberFormat = "0.00%"
End If
Next MyCell
```

ASKER CERTIFIED SOLUTION

membership

Create a free account to see this answer

Signing up is free and takes 30 seconds.

**No credit card required.**
ASKER