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

My problem is that I need to restrict cell input to a specific format. The
cell will have a total of 10 characters. The first character will be an
alpha character such as an A or a T. The last nine characters will be
numeric. The cell can contain no spaces or other characters not previously
listed. The final result would look something like A123456789.

I tried using data validation and cell formating bot neither has done enough.

I'm using Office 2003. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default limit cell input


Following code goes in the module for the particular sheet.
Right-click the sheet tab and choose "View Code"...
Change the cell address in the line noted with <<<<.
'--
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo AllOver
If Target.Address = "$B$5" Then '<<<<
Application.EnableEvents = False
If Not Target.Value Like "[a-z]#########" Then
MsgBox "alpha character followed by 9 digits only ", _
vbExclamation, "Pay Attention"
Application.Undo
End If
End If
AllOver:
Application.EnableEvents = True
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"DHSBob"
wrote in message
My problem is that I need to restrict cell input to a specific format. The
cell will have a total of 10 characters. The first character will be an
alpha character such as an A or a T. The last nine characters will be
numeric. The cell can contain no spaces or other characters not previously
listed. The final result would look something like A123456789.

I tried using data validation and cell formating bot neither has done enough.
I'm using Office 2003. Any suggestions?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default limit cell input

Jim - thanks very much. This works great!

"Jim Cone" wrote:


Following code goes in the module for the particular sheet.
Right-click the sheet tab and choose "View Code"...
Change the cell address in the line noted with <<<<.
'--
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo AllOver
If Target.Address = "$B$5" Then '<<<<
Application.EnableEvents = False
If Not Target.Value Like "[a-z]#########" Then
MsgBox "alpha character followed by 9 digits only ", _
vbExclamation, "Pay Attention"
Application.Undo
End If
End If
AllOver:
Application.EnableEvents = True
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"DHSBob"
wrote in message
My problem is that I need to restrict cell input to a specific format. The
cell will have a total of 10 characters. The first character will be an
alpha character such as an A or a T. The last nine characters will be
numeric. The cell can contain no spaces or other characters not previously
listed. The final result would look something like A123456789.

I tried using data validation and cell formating bot neither has done enough.
I'm using Office 2003. Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default limit cell input


You are welcome. The feedback is appreciated.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"DHSBob"
wrote in message
Jim - thanks very much. This works great!




"Jim Cone" wrote:
Following code goes in the module for the particular sheet.
Right-click the sheet tab and choose "View Code"...
Change the cell address in the line noted with <<<<.
'--
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo AllOver
If Target.Address = "$B$5" Then '<<<<
Application.EnableEvents = False
If Not Target.Value Like "[a-z]#########" Then
MsgBox "alpha character followed by 9 digits only ", _
vbExclamation, "Pay Attention"
Application.Undo
End If
End If
AllOver:
Application.EnableEvents = True
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





"DHSBob"
wrote in message
My problem is that I need to restrict cell input to a specific format. The
cell will have a total of 10 characters. The first character will be an
alpha character such as an A or a T. The last nine characters will be
numeric. The cell can contain no spaces or other characters not previously
listed. The final result would look something like A123456789.

I tried using data validation and cell formating bot neither has done enough.
I'm using Office 2003. Any suggestions?

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
Limit the input in a cell to a single character elevinson Excel Programming 3 November 2nd 07 08:38 PM
Limit characters in an Input Box jking80 Excel Programming 2 August 23rd 06 04:16 AM
How do I limit Input cells in MS Excel Terence Coupe Excel Programming 1 June 5th 05 09:50 AM
Limit input in a textbox James Agostinho Excel Programming 2 September 10th 03 03:10 PM
Limit character input Mike[_37_] Excel Programming 2 August 13th 03 08:18 PM


All times are GMT +1. The time now is 10:34 PM.

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"