View Single Post
  #6   Report Post  
Posted to microsoft.public.dotnet.framework,microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Zigball Zigball is offline
external usenet poster
 
Posts: 59
Default Help with creating a search engine in excel vba

Your good, and i thank you it might be simple to you but a head ache to
me. While Im discussing this with you i'd like to ask for your help
with another issue, now that i am able to search for data in my
userform i also need to be able to update the data that has been
searched for and retrieved. for instance i would search for a name
thats on the spreadsheet and i want to add that persons lastname on the
same column next to the first name. Do you know of a way that i can
achieve this type of userform. I was trying a code like this but
cannot get it to work.

Private Sub PutData()
Dim r As Long
Dim r1 As Range, r2 As Range
Set r1 = Worksheets("sheet6").Range("A1").CurrentRegion
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
Else
MsgBox "Illegal row number"
Exit Sub
End If
If r 1 And r < LastRow Then
r1.Cells(r, 1) = TextBox1.Text

DisableSave
Else
MsgBox "Invalid row number"
End If
End Sub

I believe this code is the wrong code for my userform, do you know of
any ways I can achieve update info via userform?

Ben Voigt wrote:
"Zigball" wrote in message
oups.com...
hello charles again i want to give you my full example so you can
proably understand me a little better.
example:------------------------------------------------------------

Private Sub Add_Click()
Dim r As Range
Dim ws As Worksheet
Dim SearchTxt As String
Set ws = Worksheets("sheet6")
SearchTxt = textbox1.Value
Set r = ws.Cells.Find(What:=SearchTxt, After:=ws.Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
If r Is Nothing Then Exit Sub
textbox1.Value = r.Cells(r, 1)
End Sub


Try
textbox1.Value = r.Item(1,2).Value
which should get you the value right next to the key you found

---------------------------------------------------------------------------------------------------
I want to explain that I have a userform and I want to return the
search into the userform textboxes and comboboxes etc...