Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Validation Data using Validation Table cell range..... | Excel Discussion (Misc queries) | |||
Cell Validation | Excel Worksheet Functions | |||
In Cell Validation List & Linked Cell VLOOKUP | Excel Discussion (Misc queries) | |||
Data Validation: Store cell address instead of value in the cell? | Excel Discussion (Misc queries) | |||
Cell Validation | Excel Discussion (Misc queries) |