Filling in blanks

T

trickdos

I am trying to fill in blanks in a range, with a value of 0. Can anyon
help. I have been looking at isempty formulas, and cant figure it out
I appreciate your help.

Bret
 
D

Doug Glancy

This will put a 0 in each cell in the current selection that is blank and
does not have a formula in it:

Sub test()
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula And cell.Value = "" Then
cell.Value = 0
End If
Next cell

End Sub

hth,

Doug Glancy
 
N

Norman Jones

Hi Brett,

You can readily accomplish this manually:

Function key F5 | Alt sk | Enter | 0 | Ctl Enter

If you need to do this in VBA, the equivalent would be:

Sub Test()
On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).Value = 0
On Error GoTo 0
End Sub
 
Top