Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excell cell formatting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Excell cell formatting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Excell cell formatting

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excell Cells: Auto Formatting Sophie Excel Discussion (Misc queries) 3 February 11th 10 10:31 PM
excell number formatting FRISBIE RGW Excel Worksheet Functions 3 April 20th 07 07:39 PM
Excell-Protecting sheet formatting Didas Excel Worksheet Functions 0 March 22nd 07 10:14 PM
Excell formatting Jeffery Excel Discussion (Misc queries) 3 March 4th 07 04:32 AM
How can I link a cell in Excell and keep the same formatting? Dolly Excel Worksheet Functions 1 June 7th 06 12:30 AM


All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"