Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like a selection of cells to display "-" unless text or a number is
typed in. However, if the text / number is subsequently deleted, I would like the cell to revert back to "-". Almost like the default content for the cell is "-" and not blank / empty |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put the following in Worksheet code:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("B9")) Is Nothing Then Else If IsEmpty(Target) Then Target.Value = "-" End If End If End Sub It sets up cell B9. Just expand the Intersect to include as many cells as you need. REMEMBER: worksheet code. -- Gary's Student "Matt Hannan" wrote: I would like a selection of cells to display "-" unless text or a number is typed in. However, if the text / number is subsequently deleted, I would like the cell to revert back to "-". Almost like the default content for the cell is "-" and not blank / empty |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) For Each cell In Range("A1:A10") If cell.Value = "" Then cell.Value = "-" Next cell End Sub Right-click on your worksheet tab, then click "View Code". Paste the above code. Adjust the range as necessary. Regards, Paul "Matt Hannan" <Matt wrote in message ... I would like a selection of cells to display "-" unless text or a number is typed in. However, if the text / number is subsequently deleted, I would like the cell to revert back to "-". Almost like the default content for the cell is "-" and not blank / empty |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excell Cells: Auto Formatting | Excel Discussion (Misc queries) | |||
excell number formatting | Excel Worksheet Functions | |||
Excell-Protecting sheet formatting | Excel Worksheet Functions | |||
Excell formatting | Excel Discussion (Misc queries) | |||
How can I link a cell in Excell and keep the same formatting? | Excel Worksheet Functions |