Default cell name and value

M

michael

I'm creating an excel template that I need users to populate. I want
to mark the required input cells as "<enter>"; which should equate to
zero.

If users subsequently delete their number, I want the field to default
back to "<enter>".

What's the simplest way to do this?

Mike
 
B

Bob Phillips

Put <enter> in those cells to begin, and then add

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "G1,H5,K6,L10" '<=== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, rang(WS_RANGE)) Is Nothing Then
If Target.Value = "" Then
Target.Value = "<enter>"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 

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