Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
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
Return position of 2nd, 3rd, ect occurrence of a character in a st jheby Excel Discussion (Misc queries) 5 April 21st 23 09:06 AM
Find position of first non-matching character Greg Lovern Excel Worksheet Functions 18 June 1st 08 01:52 AM
sort on character position Jimpm98 Excel Worksheet Functions 1 December 5th 06 12:16 PM
function for finding position of numeric character in a string Paul Excel Programming 5 February 6th 05 12:19 AM
Newbie VBA: How to test second position in a cell? ZoomZoom[_5_] Excel Programming 1 June 3rd 04 03:58 PM


All times are GMT +1. The time now is 02:25 AM.

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"