DrCheese1023
New Member
- Joined
- Jun 28, 2021
- Messages
- 10
- Office Version
- 2019
- Platform
- Windows
I am creating a UserForm that is pulling records of my customers from a worksheet to my UserForm using this code:
The data is then populating this form:
This is fine, but my customers that I am looking up have multiple records, and I want a function that selects the next record down that falls into the XLookup criteria.
TLDR, i want to press a button that shows the next thing down a list that my xlookup would be returning.
VBA Code:
```
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
```
The data is then populating this form:
This is fine, but my customers that I am looking up have multiple records, and I want a function that selects the next record down that falls into the XLookup criteria.
TLDR, i want to press a button that shows the next thing down a list that my xlookup would be returning.