ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Default Value to Number cell (https://www.excelbanter.com/excel-programming/352347-default-value-number-cell.html)

Rick_C

Default Value to Number cell
 
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

Kevin B

Default Value to Number cell
 
You can create the following procedu

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.
--
Kevin Backmann


"Rick_C" wrote:

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



All times are GMT +1. The time now is 03:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com