|
-
Aug 30th, 2002, 11:17 AM
#1
Thread Starter
New Member
vba excel
working on a search of excel wrkbk, with a user form out front. would rather be doing it in access but need to keep it thin for distribution. Having problems trying to deeal with partial search entries, looking for n1234abc but enter n1234, want to bring up all that contain the partial if someone does't know the whole part number or if they enter it wrong.
any ideas would be greatly appreciated
been trying to do it in VBA.
-
Sep 1st, 2002, 01:08 AM
#2
Member
I have not dealt with Excel much but I can help you with the partial entry.
Say they are searching for n1234 and the string you are searching is n1234abc. You could do this:
Dim testlike
testlike = "n1234abc" Like "*n1234*"
If testlike = True Then
MsgBox ("we have a match")
Else
MsgBox ("no match")
End If
Hope that helps.
-
Sep 3rd, 2002, 09:28 AM
#3
Thread Starter
New Member
vab excel
Thank you fro your help, That may not be the exact way but you gave me some ideas and got me going in another direction,
thank you very much.
-
Sep 3rd, 2002, 02:19 PM
#4
Hyperactive Member
To test this code, open a new workbook, add a UserForm with 2 textboxes & 1 command button to this workbook (leaving the names defaulted), and paste this code into UserForm code window. Add a module & put add a macro to show the userform.
Enter data on the worksheet & run the macro.
VB Code:
Option Explicit
Private strFirstCell As String
Private Sub CommandButton1_Click()
Static c
Sheets("Sheet1").Select
If CommandButton1.Caption = "Find" Then
Range("A1").Select
strFirstCell = ""
Set c = Cells.Find(What:=TextBox1.Text, LookIn:=xlValues, LookAt:=xlPart, _
MatchCase:=False)
If Not c Is Nothing Then
c.Select
strFirstCell = ActiveCell.Address
TextBox2.Text = c.Value
CommandButton1.Caption = "Find Next"
End If
Else
Set c = Cells.FindNext(After:=ActiveCell)
If Not c Is Nothing Then
c.Select
If ActiveCell.Address = strFirstCell Then
MsgBox "All partial strings found."
CommandButton1.Caption = "Find"
Else
TextBox2.Text = c.Value
End If
End If
End If
End Sub
Hope this helps.
Nate
-
Sep 3rd, 2002, 03:20 PM
#5
Thread Starter
New Member
vba excel
Thank you very much for your help, with a little tweaking I believe this could be the answer to my prayers. Thank you for taking the time to help me it is greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|