LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Writing A Search Macro With Wildcard Characters?

If anyone has enough time to help me with this matter, it would be
greatly appreciated. Here is some needed set-up info. and what I am
trying to accomplish.

I have a list in the form of an array(actually its a multi-column
array, but only one column is being utilized in this particular macro).
On a sheet is a textbox and a command button. What I would like to
accomplish is that when a user types an entry in the textbox and clicks
the "Search" command button, the attached macro will loop through the
list returning one of two results.
A) It runs a loop through the list and if an exact match is found, the
found match and coinciding info(found in the other columns of the
array) are written to specific cells to later be displayed on a
userform that will pop up after the former code is exhausted.

B)If an exact match isn't found on the first loop, a second loop is run
through the same list and populates a combobox on another userform with
the next closest matches for the user to pick from. (In essence if the
user was searching for "poetry" and the 1st. loop doesn't find it, the
second loop will look for all other instances comprised of "po*")

I have completed A) but am pulling my hair out with B)...the code for
A) looks like this....

Private Sub ASSearch_Click()

Dim r1 As Integer

'loop through skills on ctrl sheet to find skill being searched
r1 = 0
Do
r1 = r1 + 1
'if skill being searched is found, paint skill name, number of ranks,
and bonus to ctrl sheet
If Sheet4.Range("CtrlSkills").Cells(r1, 2) = ASSkillSearchBox.Value
Then
Sheet4.Range("CtrlSkillID") = Sheet4.Range("CtrlSkills").Cells(r1,
2)
Sheet4.Range("CtrlRanks") = Sheet4.Range("CtrlSkills").Cells(r1, 3)
Sheet4.Range("CtrlBonus") = Sheet4.Range("CtrlSkills").Cells(r1, 8)
End If
Loop Until Sheet4.Range("CtrlSkills").Cells(r1, 2) = ""

'loop through skill again, stopping at skill being searched for
If Sheet4.Range("CtrlSkillID") = ASSkillSearchBox.Value Then
r1 = 0
Do
r1 = r1 + 1
Loop Until Sheet4.Range("CtrlSkills").Cells(r1, 2) =
ASSkillSearchBox.Value

'from found skill loop up and stop at catagory name
Do
r1 = r1 - 1
Loop Until Sheet4.Range("CtrlSkills").Cells(r1, 1) = "c"

'paint catagory name to ctrl sheet
Sheet4.Range("CtrlCatagoryName") =
Sheet4.Range("CtrlSkills").Cells(r1, 2)

'return skill information in skill return userform
ASSkillReturn.Show
Else
'open closest matches userform
ASSkillMatch.Show
End If

End Sub

I am an amateur vba user and self taught...I am six months into this
program and learning a lot but this seems to be a "code" I can't crack.
Is what I'm trying to do possible and if so can anybody give me advice
on how to accomplish it.

Thank You
Kevin a.k.a. "Torahn"

 
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
Use of Wildcard characters with replace tonuab Excel Discussion (Misc queries) 2 November 6th 09 09:39 PM
can wildcard characters be used in IF functions Ligaya Excel Worksheet Functions 1 January 24th 07 01:02 PM
wildcard characters Hasty Excel Discussion (Misc queries) 2 July 21st 06 10:40 AM
HELP: Wildcard Characters bbddvv Excel Discussion (Misc queries) 0 June 28th 06 02:38 PM
WildCard Characters Ralph Heidecke Excel Worksheet Functions 1 June 1st 06 07:43 PM


All times are GMT +1. The time now is 01:18 PM.

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"