Blank Cells to display as $0

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
915
Office Version
  1. 365
Platform
  1. Windows
I am sure this is easy but I cannot remember how to do it and cannot find what I am looking for online.
I am making a calculator in excel and want certain ranges of blank cells to show as $0 before anything is entered, however if the user clears the cell it will revert back to displaying $0.

I would also like to be able to change the $0 value to a default value of my choice for one or more of the cells. Can this be achieved in VBA running in the background?

Help with this would be greatly appreciated.

Thank you
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
It sounds like if someone presses "delete", then you want a given value to populate the cell? If so, populate the range with the default value. Right click on the sheet tab on the bottom and select View Code. Paste this code in the window that opens:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    Application.EnableEvents = False
    
    If Not Intersect(Target, Range("B2:B8")) Is Nothing Then
        If Target.Value = "" Then Target.Value = 0
    End If
    
    If Not Intersect(Target, Range("C2:C8")) Is Nothing Then
        If Target.Value = "" Then Target.Value = 100
    End If
    
    Application.EnableEvents = True

End Sub

Change the ranges to match your sheet (B2:B8 and C2:C8 in this example). Change the values to what you want (0 and 100 here). Let us know if this is what you want.
 
Upvote 0
Hello Willow, you can try to do that with custom cell formatting.
[<>0]#,##0.00;;"$0"
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top