我正在创建一个用户窗体,它使用以下代码将我的客户记录从工作表提取到我的用户窗体:
Sub employeelookup()
SalesForm.BHSDEMPLOYEETD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("F:F"))
End Sub
Sub salesoriginlookup()
SalesForm.BHSDSALESORIGINTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("W:W"))
End Sub
Sub contactdatelookup()
SalesForm.BHSDCONTACTDATETD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("H:H"))
End Sub
Sub saleamountlookup()
SalesForm.BHSDSALEAMOUNTTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("J:J"))
End Sub
Sub companynamelookup()
SalesForm.BHSDCOMPANYNAMETD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("O:O"))
End Sub
Sub customernamelookup()
SalesForm.BHSDCUSTOMERNAMETD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("L:L"))
End Sub
Sub addresslookup()
SalesForm.BHSDADDRESSTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("M:M"))
End Sub
Sub cszlookup()
SalesForm.BHSDCSZTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("N:N"))
End Sub
Sub phonelookup()
SalesForm.BHSDPHONENUMBERTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("E:E"))
End Sub
Sub emaillookup()
SalesForm.BHSDEMAILTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("AH:AH"))
End Sub
Sub pmtdatelookup()
SalesForm.BHSDPMTDATETD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("R:R"))
End Sub
Sub pmtamtlookup()
SalesForm.BHSDPMTAMTTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("S:S"))
End Sub
Sub adminnoteslookup()
SalesForm.BHSDADMINNOTESTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("U:U"))
End Sub
Sub tsrnoteslookup()
SalesForm.BHSDTSRNOTESTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("AD:AD"))
End Sub
Sub camplookup()
SalesForm.BHSDCAMPTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("B:B"))
End Sub
Sub emailreceiptlookup()
SalesForm.BHSDEMAILRECEIPTTD.Value = Application.XLookup(Val(SalesForm.BHSDMAINNUMBERLF.Value), Worksheets("TELEDATA").Range("E:E"), Worksheets("TELEDATA").Range("AF:AF"))
End Sub
数据然后填充此表格:
这很好,但是我正在查找的客户有多个记录,我想要一个函数来选择下一个符合 XLookup 标准的记录。
TLDR,我想按下一个按钮,显示我的 xlookup 将返回的列表中的下一个内容。