Need help with a macro

  • Thread starter Thread starter Aaron Cooper
  • Start date Start date
A

Aaron Cooper

I'm sure someone out there has a macro to do this, so here goes.
I need to put zeros in cells which have no data in them within a
specified range and do nothing to cells which have a value in them.
Here is the problem... I need the macro to ask me to input that
specified range each time I run the macro. I hope that someone out
there can help me out. I'm pretty much a novice on macro programming
and could use some help here.

Thanks in advance.
 
Aaron

Sub Add_Zero()
Dim cel As Range
Dim sRange As Range
Set sRange = Application.InputBox(prompt:= _
"Select the range of cells.", Type:=8)
For Each cel In sRange
If cel.Value = "" Then
cel.Value = 0
End If
Next
End Sub

Note: you can select the range with the Mouse or type the range into the box.

Gord Dibben Excel MVP
 
Thank you all so much. You've saved me hours. There is no way that
you could comprehend the amount of time that you have saved me from
either trying to figure this out on my own or filling all of the cells
in manually.

Thanks again,

Aaron
 
Back
Top