ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User Form to display more than 1 reslut (https://www.excelbanter.com/excel-programming/307727-user-form-display-more-than-1-reslut.html)

EstherJ

User Form to display more than 1 reslut
 
I have the following function which looks at a list of data when "Cust" -
(customers name) is specified and returns the sales rep and sales value. The
function finds the first occurence of that name in the list. I would like it
to display all occurences. I would be grateful for any ideas.


Private Sub Retrieve_Click()
Dim Cust As Range
With Range("Custdata")
Set Cust = .Find(CUstname.Value)
If Cust Is Nothing Then
MsgBox ("Customer not found!")
CUstname.Value = " "
Exit Sub
Else
With Range(Cust.Address)
Salesrep = .Offset(0, 3)
LinevalueGBP = .Offset(0, 16)
End With
End If
End With
End Sub

Thank you,

Esther

Tom Ogilvy

User Form to display more than 1 reslut
 
Look at the Excel VBA help example for the findnext command. It shows you
how to find multiple instances of a search string in a range.

--
Regards,
Tom Ogilvy

"EstherJ" wrote in message
...
I have the following function which looks at a list of data when "Cust" -
(customers name) is specified and returns the sales rep and sales value.

The
function finds the first occurence of that name in the list. I would like

it
to display all occurences. I would be grateful for any ideas.


Private Sub Retrieve_Click()
Dim Cust As Range
With Range("Custdata")
Set Cust = .Find(CUstname.Value)
If Cust Is Nothing Then
MsgBox ("Customer not found!")
CUstname.Value = " "
Exit Sub
Else
With Range(Cust.Address)
Salesrep = .Offset(0, 3)
LinevalueGBP = .Offset(0, 16)
End With
End If
End With
End Sub

Thank you,

Esther





All times are GMT +1. The time now is 10:05 PM.

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