Hi all. I have a question which might be a bit tricky or unfeasible. But anyway, here it goes:
In my worksheet, I have a searchbox which reads "Please type claim name below". Then when the string is typed by the user and the user presses search, a search takes place. All the values are then returned into a listbox below (ListBox1). When a value from the listbox is selected, and the go button is pressed, the entire row which contains the string is selected. Unfortunately, many of the claim names are the same, so it would be impossible for a user to know which is the right string to select. Now, each claim name belongs to a particular claimant in another column. So there might be several claims that have the name of "Land", but the claimants, listed in the adjacent column, would be different.
i.e.
A B
(Claimant) (Claim)
John Doe Land
Suzy Q Land
Bob **** Loss of Use
etc.
My Question: Is there a way to have both adjacent columns appear in the listbox when the user makes a search. So if "Land" is returned, for example, the following would appear in the listbox:
John Doe Land
Suzy Q Land
My code is below. Thanks for any help or ideas!
Private Sub btnGoTo_Click() If IsNull(Me.ListBox1.Value) Then MsgBox "Please select an item from the list.", vbOKOnly Exit Sub End If Sheets("Master").Rows(Me.ListBox1.Column(1, Me.ListBox1.ListIndex)).Select Unload Me MovingClaim End Sub Private Sub btnSearch_Click() Dim rng As Range Dim intRow As Integer Dim start As Range If Me.TextBox1.Value = "" Then MsgBox "Type in something to search for" Exit Sub Else With Sheets("Helper") Set rng = Sheets("Master").UsedRange.Find(Me.TextBox1.Value) Set start = rng Do intRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1 .Cells(intRow, 1).Value = rng.Value .Cells(intRow, 2).Value = rng.Row Set rng = Sheets("Master").UsedRange.FindNext(rng) Loop While Not rng Is Nothing And rng.Address <> start.Address End With End If Me.ListBox1.RowSource = "Helper!A2:B" & Sheets("Master").Cells(Rows.Count, 1).End(xlUp).Row End Sub Private Sub ListBox1_Click() End Sub Private Sub UserForm_Initialize() Sheets("Helper").Range("A2:B" & Sheets("Helper").Cells(Rows.Count, 1).End(xlUp).Row + 1).ClearContents End Sub
Last edited by touchofknowledge; 12-08-2011 at 10:41 AM.
It would be better if you did upload the file.
you can add another combo box to list the applicable Claimants
SAMPLEEXERCISE.XLS
Hi There. File should be attached. This is not the file I'm using (since the claimants are all confidential), but something I threw together that should get the idea across. I would like the claimant name to show up along with the claim when I search.
Thanks!
Okay, hopefully this attachment works!
maybe 3-column listbox?
Okay, but how would I go about that?
I'm sorry, but my attachment is lost. Can you attach your sample file again?
I'll try this upload again. The security system where I work is fairly intense so I'm not sure if it'll upload properly... our browsers aren't exactly up to dateAttachment 131762
See the attached file (attempt #2)
Hmm. It doesn't seem to be there... and the file I attached is no longer working (I swear the link worked before, I guess the links are temporary)...
I will try to attach a file again. Download immediately until it disappeared.![]()
That is brilliant. Thank you so much!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks