Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How do I prevent text entering?

I have a spreadsheet where a default in a field is changed by a double
click. A second double click will return the field to the default.

I only need the field to show the 'default' or the 'alternate' entry.
No other entry is needed.

How do I prevent an operator from entering text?

Thanks,

Robin Chapple
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default How do I prevent text entering?

One way is to use Data Validation
If I knew more of what you are needing I could help a little more

"Robin Chapple" wrote:

I have a spreadsheet where a default in a field is changed by a double
click. A second double click will return the field to the default.

I only need the field to show the 'default' or the 'alternate' entry.
No other entry is needed.

How do I prevent an operator from entering text?

Thanks,

Robin Chapple

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I prevent text entering?

Maybe you could use a worksheet event:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)

Dim DefaultVal As Variant

DefaultVal = "hi there!"

With Target
If .Cells.Count 1 Then Exit Sub
If Intersect(.Cells, Me.Range("a1")) Is Nothing Then Exit Sub

Cancel = True 'stop from editing the cell

On Error GoTo ErrHandler:

Application.EnableEvents = False
If .Value = DefaultVal Then
'change it to what you want
.Value = "Good Bye"
Else
.Value = DefaultVal
End If
End With

ErrHandler:
Application.EnableEvents = True

End Sub

Change A1 to the cell's address that you need.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/Events.aspx

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

And the macro will not work if the user disables macros or disables events.


Robin Chapple wrote:

I have a spreadsheet where a default in a field is changed by a double
click. A second double click will return the field to the default.

I only need the field to show the 'default' or the 'alternate' entry.
No other entry is needed.

How do I prevent an operator from entering text?

Thanks,

Robin Chapple


--

Dave Peterson
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
Entering Variable Text in Text Boxes...... Steve Jones Excel Discussion (Misc queries) 3 June 14th 07 02:34 PM
entering text William Excel Discussion (Misc queries) 2 February 3rd 07 02:41 PM
How do I prevent entering duplicate numbers in an excel worksheet Bran5956 Excel Worksheet Functions 1 October 23rd 06 06:03 PM
Entering text in cells Hallway Excel Discussion (Misc queries) 4 September 26th 06 04:49 AM
When entering numbers as text jmcme Excel Discussion (Misc queries) 1 August 1st 05 10:15 PM


All times are GMT +1. The time now is 09:51 AM.

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

About Us

"It's about Microsoft Excel"