Listbox

laurawr

New Member
Joined
Mar 3, 2011
Messages
32
Hi,

On a userform I have a listbox, a textbox and a combo box.

The combo box contains the headings of each column populated via

Code:
 columncmb.AddItem Cells(1, c).Text


I want this to specify what column to look in for the text typed in the text box.

When the data is found I would like the full row(s)of data to be entered into the listbox

Is there any way I can do this?

Regards

L
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi,

Well I have sorted this and made something that works however when the data has been placed into the listbox after a search it leave alot of blank rows underneath the data. I want rid of the blank rows that the listbox is showing.

Code:
 Private Sub search_Click()
If columncmb = 0 Then
MsgBox "Please choose a Search category."
Exit Sub
Else
 
If Searchtext.Text = "" Then
 
MsgBox "Please Enter a Search Criteria."
Searchtext.SetFocus
Exit Sub
Else
Application.ScreenUpdating = False
ThisWorkbook.Sheets("HPIN Index").Visible = True
ThisWorkbook.Activate
ThisWorkbook.Sheets("HPIN Index").Select
 
Dim DataSH As Worksheet
Set DataSH = Sheets("HPIN Index")
DataSH.Range("L1").Value = columncmb.Value
DataSH.Range("L2").Value = "*" & Searchtext.Text & "*"
DataSH.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, criteriarange:=DataSH.Range("L1:L2"), copytorange:=DataSH.Range("M1:U141")
ListBox1.RowSource = DataSH.Range("DATA").Address
 
 
Application.ScreenUpdating = True
ThisWorkbook.Sheets("HPIN Index").Visible = False
End If
End If
End Sub

Regards
L
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,792
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top