![]() |
#2
|
|||
|
|||
![]()
Found it myself!
Code:
Sub check_format() Dim ok As Boolean Dim str As String 'select the cell to check and run the macro - "ok" is the boolean that will... '...determine whether the pattern is matching. It is set to true if the cell matches... '...one of the allowed patterns. str = Selection.Value ok = False Select Case True Case str Like "##[.]": ok = True Case str Like "##[.]##[.]": ok = True Case str Like "##[.]##[.]##[.]": ok = True Case str Like "##[.]##[.]##[.]##[.]": ok = True End Select If ok = False Then MsgBox ("Wrong pattern!") Else MsgBox ("Pattern is ok!") End If End Sub I do like the "case" method as it is very readable and easy/convenient to add or delete new patterns. Cheers! |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Amitti | Word VBA | 2 | 04-10-2017 07:35 PM |
Is there a way to delete the beginning part of an array so it doesn't overflow? | omahadivision | Excel Programming | 4 | 01-15-2014 11:22 PM |
![]() |
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
Spell check checking only part of document | Adeyo | Word | 1 | 02-24-2013 10:49 PM |
![]() |
tinfanide | Excel Programming | 4 | 12-26-2012 08:56 PM |