#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 587
Default Cell validation

hi,

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, c As String, res As String, i As Integer
Set rng = Range("A1:A10") 'Adapt this range as your wish
Set isect = Application.Intersect(Target, rng)
txt = Array( _
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", _
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", _
"", "à", "é", "è") ' you can add characters the way you want

If Not isect Is Nothing Then
For i = 1 To Len(Target)
c = Mid(Target, i, 1)
If IsError(Application.Match(c, txt, 0)) Then res = res & Mid(Target, i, 1) & ", "
Next
If Len(Target) 2 And Len(Target) < 35 Then
If res = "" Then
Exit Sub
Else
MsgBox "The following characters are forbidden : " & res & Chr(10) & _
"Please start again" & Chr(10) & _
"Don't forget : only alphabets of length 3 to 35"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
Exit Sub
End If
Else
MsgBox "Don't forget : only alphabets of length 3 to 35"
End If
End If
End Sub



--
isabelle



Le 2012-01-06 04:49, KRISHNA a écrit :
Hi,
Would need a macro to restrict a set of cells with only alphabets of length 3 to 35

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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Cell Validation Richhall[_2_] Excel Worksheet Functions 2 January 2nd 08 10:34 AM
In Cell Validation List & Linked Cell VLOOKUP BEEZ Excel Discussion (Misc queries) 7 July 1st 07 07:17 PM
Data Validation: Store cell address instead of value in the cell? WillW Excel Discussion (Misc queries) 1 January 31st 07 02:22 AM
Cell Validation Simon Shaw Excel Discussion (Misc queries) 5 March 3rd 05 11:51 PM


All times are GMT +1. The time now is 05:37 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"