Default Value to Number cell

G

Guest

Cell D8 is formated as a number cell and unprotected.

How can I make ZERO ("0") the default value of this cell? Even if the user
hits the delete button a ZERO needs to be re-inserted.

Thanks in advance for your assistance.

Rick
 
G

Guest

You can create the following procedure:

Sub NeverBlank()

Dim wb As Workbook
Dim ws As Worksheet
Dim varVal As Variant

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet

varVal = Range("A1").Value

If Len(varVal) = 0 Then
Range("A1").Value = 0
End If

Set wb = Nothing
Set ws = Nothing

End Sub


And then invoke it from by running it from the Worksheets change event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top