PDA

View Full Version : Solved: problem with application.match



nether
01-25-2006, 01:24 AM
Hi guys,

I have a small problem. I have made an excelsheet with userforms to keep up with all the patches made here in the serverroom at the office.

So far so good. I have almost finished the excelsheet, and want to bring it into "production". However, with the last searchfunction i have a problem. With this code i use the value of a combobox to lookup a value in the excelsheet. If that value is found, a msgbox is shown with the data that belongs to that value. however it doesn't matter what i type in, it just keeps saying it doesn't find any data in the sheet.

For other data in the excelsheet the code works, but for looking up a number it doesn't work. Could you guys help me please? I have looked for an error in the code, but can't find one. Here is the code:

/vb
Private Sub CommandButton1_Click()
Dim searchvalue As String, srchrange As Range, foundrow As Variant, finalrow As Long, x, foundrowtrue
searchvalue = ComboBox1.Value
Set srchrange = Sheets("patches-walloutlet").Range("C2:C30")
foundrow = Application.Match(searchvalue, srchrange, 0)
If IsError(foundrow) Then
MsgBox "error"
Else
foundrowtrue = foundrow + 1
MsgBox "Telefoonnummer " & searchvalue & " is aangesloten op walloutlet " & vbNewLine & _
Sheets("patches-walloutlet").Range("A" & foundrowtrue).Value & _
" op " & Sheets("patches-walloutlet").Range("F" & foundrowtrue).Value & _
" poort " & Sheets("patches-walloutlet").Range("G" & foundrowtrue).Value & ". Dit telefoonummer " & _
" is van " & Sheets("patches-walloutlet").Range("H" & foundrowtrue).Value & "."
End If
Unload Me
Datafind.Show
End Sub
/vb

Any help would be appreciated!!

Thanks

Rolf:bow: :bow: :bow:

jindon
01-25-2006, 01:33 AM
Dim searchvalue As String

Make sure the type of data is the same...

jindon
01-25-2006, 01:34 AM
Oops!

nether
01-25-2006, 07:17 AM
Searchvalue is a number. Should I use integer then?

nether
01-25-2006, 07:27 AM
i used integer, and it worked!! thanks for the hint!