Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
proximity position test for character(s) function - an example
No question here, just a custom function example for the archive.
Test if A (or a combination of characters) is positioned to the left of B (or a combination of characters) by specified spaces in between A and B case sensitivity is an optional arguement in function Function NearEachOther(TargetCell As String, CompareChar As String, Next2ThisChar As String, SpacesInBetween As Long, Optional casesensitive) As Boolean ' Returns TRUE if A (or a combination of characters) is positioned to the 'left of B (or a combination of characters) by specified spaces in between A and B If CompareChar = "" Or TargetCell = "" Then NearEachOther = Evaluate("NA()") Exit Function End If If IsMissing(casesensitive) Then casesensitive = 0 Select Case casesensitive 'Note: currently this function is set up to check if A is positioned ' the LEFT of B (A_B). To check for A to the RIGHT of B (B_A), 'edit the section below by switching the places of string variables 'CompareChar and Next2ThisChar in the code. Case 0 ''zero or missing If TargetCell Like "*" & CompareChar & WorksheetFunction.Rept(Chr(63), SpacesInBetween) & Next2ThisChar & "*" Then NearEachOther = True Else NearEachOther = False Case Else ''any non-zero 3rd argument If UCase(TargetCell) Like "*" & UCase(CompareChar) & WorksheetFunction.Rept(Chr(63), SpacesInBetween) & UCase(Next2ThisChar) & "*" Then NearEachOther = True Else NearEachOther = False End Select End Function Seach criteria: proximity test for characters test for character positions near each other evaluate character positions check for character positioning evaluate character order in string find specific character spacing are specific characters next to or near each other? evaluate spacing |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Return position of 2nd, 3rd, ect occurrence of a character in a st | Excel Discussion (Misc queries) | |||
Find position of first non-matching character | Excel Worksheet Functions | |||
sort on character position | Excel Worksheet Functions | |||
function for finding position of numeric character in a string | Excel Programming | |||
Newbie VBA: How to test second position in a cell? | Excel Programming |