ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Find record by multi criteria in userform (https://www.excelbanter.com/excel-discussion-misc-queries/208783-find-record-multi-criteria-userform.html)

MP

Find record by multi criteria in userform
 
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.Val ue, _
, , 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


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com