Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Search wildcard to limit only alpha characters

The user wants to find a record on a list. He enters a PO#, and it
searches the list.
Example. User enters in M123456.
The list contains this number, but also has M123456A, M123456B and
M123456C.
The userform comes up showing the 1st record, M123456.

The code below is in the useform, and it counts the number of records
with the PO#, plus variations at the end of the PO#. In the above
example, Texbox 25 will show the number 4. This works fine.

CountPO = Application.CountIf(Range("POCurrent_Column"), FindPOVal &
"*")
TextBox25.Value = CountPO

What I want is to narrow it down to cause the wildcard in the above
code (FindPOVal & "*") to only look for alpha characters at the end
of the value FindPOVal.

So, if M123456 and M123456A, M123456B and M123456C are on the list,
textbox 25 will correctly show the number 4. BUT, if for some reason
there is also M123456789 on the list, it won't be counted, and textbox
25 will still show the number 4.

Thanks,
J.O.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Search wildcard to limit only alpha characters

Sub AAA()
Dim countPO As Long, v As Variant
Dim i As Long, s As String
Dim FindPoval As String
FindPoval = "M123456"
v = Range("POCurrent_Column")
countPO = 0
For i = LBound(v) To UBound(v)
If InStr(1, v(i, 1), FindPoval, vbTextCompare) = 1 Then
If Len(v(i, 1)) = Len(FindPoval) Then
countPO = countPO + 1
Else
s = Right(v(i, 1), Len(v(i, 1)) - Len(FindPoval))
If Not IsNumeric(Left(s, 1)) Then
countPO = countPO + 1
End If
End If
End If
Next
TextBox25.Value = countPO

End Sub

--
Regards,
Tom Ogilvy


"excelnut1954" wrote:

The user wants to find a record on a list. He enters a PO#, and it
searches the list.
Example. User enters in M123456.
The list contains this number, but also has M123456A, M123456B and
M123456C.
The userform comes up showing the 1st record, M123456.

The code below is in the useform, and it counts the number of records
with the PO#, plus variations at the end of the PO#. In the above
example, Texbox 25 will show the number 4. This works fine.

CountPO = Application.CountIf(Range("POCurrent_Column"), FindPOVal &
"*")
TextBox25.Value = CountPO

What I want is to narrow it down to cause the wildcard in the above
code (FindPOVal & "*") to only look for alpha characters at the end
of the value FindPOVal.

So, if M123456 and M123456A, M123456B and M123456C are on the list,
textbox 25 will correctly show the number 4. BUT, if for some reason
there is also M123456789 on the list, it won't be counted, and textbox
25 will still show the number 4.

Thanks,
J.O.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Search wildcard to limit only alpha characters

On Feb 22, 9:07 am, Tom Ogilvy
wrote:
Sub AAA()
Dim countPO As Long, v As Variant
Dim i As Long, s As String
Dim FindPoval As String
FindPoval = "M123456"
v = Range("POCurrent_Column")
countPO = 0
For i = LBound(v) To UBound(v)
If InStr(1, v(i, 1), FindPoval, vbTextCompare) = 1 Then
If Len(v(i, 1)) = Len(FindPoval) Then
countPO = countPO + 1
Else
s = Right(v(i, 1), Len(v(i, 1)) - Len(FindPoval))
If Not IsNumeric(Left(s, 1)) Then
countPO = countPO + 1
End If
End If
End If
Next
TextBox25.Value = countPO

End Sub

--
Regards,
Tom Ogilvy



"excelnut1954" wrote:
The user wants to find a record on a list. He enters a PO#, and it
searches the list.
Example. User enters in M123456.
The list contains this number, but also has M123456A, M123456B and
M123456C.
The userform comes up showing the 1st record, M123456.


The code below is in the useform, and it counts the number of records
with the PO#, plus variations at the end of the PO#. In the above
example, Texbox 25 will show the number 4. This works fine.


CountPO = Application.CountIf(Range("POCurrent_Column"), FindPOVal &
"*")
TextBox25.Value = CountPO


What I want is to narrow it down to cause the wildcard in the above
code (FindPOVal & "*") to only look for alpha characters at the end
of the value FindPOVal.


So, if M123456 and M123456A, M123456B and M123456C are on the list,
textbox 25 will correctly show the number 4. BUT, if for some reason
there is also M123456789 on the list, it won't be counted, and textbox
25 will still show the number 4.


Thanks,
J.O.- Hide quoted text -


- Show quoted text -


Thanks, Tom. I'll give it a try later today. I appreaciate your help.
J.O.

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
Search list for non-alpha characters Ted Metro Excel Worksheet Functions 9 October 19th 07 07:40 PM
WILDCARD CHARACTERS F. Lawrence Kulchar Excel Programming 3 September 20th 06 10:10 AM
Writing A Search Macro With Wildcard Characters? [email protected] Excel Programming 5 July 28th 06 04:41 PM
wildcard characters Hasty Excel Discussion (Misc queries) 2 July 21st 06 10:40 AM
Wildcard for ALPHA only Eva at Work Excel Discussion (Misc queries) 3 March 31st 06 04:44 PM


All times are GMT +1. The time now is 02:28 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"