Find record by multi criteria in userform

M

MP

I'm using a find button in my userform to extract data in the worksheet row
by account name and pull the data into the userform. However, if there
muliple accounts with the same name the data will not pull correclty.

Is there a way I can modify the below code so the find button will pull the
information by the account name and matching file number associated with the
account name. I assigned each account name with a unique file ID number in a
separate column. The properties name for the unique file ID num is filenum.
Thanks

Code:
Private Sub cmdbranch_Click()
Dim rn As Range
If combranch <> "" Then
'ClearData
Set rn = Sheet1.Range("B2 ",
Sheet1.Range("B2").End(xlDown)).Find(combranch.Value, _
, , xlWhole, , xlNext)
If Not rn Is Nothing Then
DisableSave
Filenum.Value = rn.Offset(0, -1)

Actname.Value = combranch.Value
daterec.Value = rn.Offset(0, 1)
dateneed.Value = rn.Offset(0, 2)
datecomp.Value = rn.Offset(0, 3)
status1.Value = rn.Offset(0, 4)
vendor1.Value = rn.Offset(0, 5)
Actype1.Value = rn.Offset(0, 6)
Dept1.Value = rn.Offset(0, 7)
uw1.Value = rn.Offset(0, 8)

C.Value = rn.Offset(0, 9)
Q.Value = rn.Offset(0, 10)
EM.Value = rn.Offset(0, 11)
MR.Value = rn.Offset(0, 12)
MRC.Value = rn.Offset(0, 13)
EX.Value = rn.Offset(0, 14)
SP.Value = rn.Offset(0, 15)
RM.Value = rn.Offset(0, 16)
L.Value = rn.Offset(0, 17)
N.Value = rn.Offset(0, 18)
D.Value = rn.Offset(0, 19)
E.Value = rn.Offset(0, 20)
P.Value = rn.Offset(0, 21)
B.Value = rn.Offset(0, 22)
G.Value = rn.Offset(0, 23)
I.Value = rn.Offset(0, 24)
CR.Value = rn.Offset(0, 25)
S.Value = rn.Offset(0, 26)
CL.Value = rn.Offset(0, 27)
srvtype.Value = rn.Offset(0, 28)
Request1.Value = rn.Offset(0, 29)
otherdes.Value = rn.Offset(0, 30)
ActDes.Value = rn.Offset(0, 31)
subnum.Value = rn.Offset(0, 32)
polnum.Value = rn.Offset(0, 33)
UserForm1.rownumber.Value = Filenum.Value + 1

Else
MsgBox "Account Name not found. Please Try Again."
End If
Else
combranch.Text = "Please Enter Account Name."
End If
Set rn = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Transfer Writen Notes 0
Userforms..... 0

Top