Home |
Search |
Today's Posts |
#13
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
True, but Like is a VB programming concept and my guess is that most Excel
users are not VB literate, so I would think many (if not most) of the users would not be familiar with Like's operator patterns. However, I think we can cater to both types of users with something like this (off the top of the head code) maybe... Function Foo(A As Variant, ByVal P As String, _ Optional C As Boolean) As Double Dim X As Variant If Not P Like "*[*?#[]*" Then P = "*[" & P & "]*" If Not TypeOf A Is Range And Not IsArray(A) Then A = Array(A) For Each X In A If C Then If UCase(X) Like UCase(P) Then Foo = Foo + 1 ElseIf X Like P Then Foo = Foo + 1 End If Next X End Function If the user uses an asterisk, question mark, hash mark or left square bracket in his/her pattern string, then the code assumes the user has constructed a Like pattern string and passes it through as it; if none of those characters are present, then the code assumes the user is looking for a simple letter match. The optional C argument still optionally allows for case sensitive or case insensitive searches. -- Rick (MVP - Excel) "Harlan Grove" wrote in message ... "Rick Rothstein" wrote... I like this idea better than my paramarray suggestion; however, I would change your function slightly so the user would not have to know the syntax of the Like operator... ... IMO, better for users to know the syntax for LIKE operator patterns since that would allow significantly greater flexibility and functionality than simply searching for alternative single characters. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count Functions | Excel Discussion (Misc queries) | |||
Count Functions | Excel Worksheet Functions | |||
Fun with COUNT and AND functions. | Excel Worksheet Functions | |||
functions to count Yes & No | Excel Worksheet Functions | |||
Excel IF and COUNT functions | Excel Worksheet Functions |