ListBox Result

  • Thread starter Thread starter Randal W. Hozeski
  • Start date Start date
R

Randal W. Hozeski

I have a single select ListBox1 that contains unique
items from a list called "Data". I want to do subs with
the returned value of the Listbox.

1. Take selected item and delete all records (lines) with that unique
item. If that is the last item in "Data" an error handler to still
maintain the name and ListBox.

2. Take selected item and then AutoFilter by it. ending it by selecting
the items filtered by excluding headers.

3. Copy and paste that value in a cell on a different page.

-Randy-

..
 
Hi Randy,

You can know the selected value with this code.

Code:
--------------------

ListBox1.list(ListBox1.listindex)

--------------------


If MultiSelect has been used, need to loop like this.


Code:
--------------------

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
MsgBox "Item " & i + 1 & " has been Selected"
End If
Next

--------------------


Regarding to how to copy Autofiltered(excluding headers) range would be
as follows.


Code:
--------------------

With Sheets(1).AutoFilter.Range
.Resize(.Rows.Count - 1).Offset(1).Copy Sheets(2).Cells(1, 1)
End With

--------------------
 
I think my AutoFilter question was misunderstood.
It is to AutoFilter whatever is selected from
a single select ListBox (the result) not copy it.

-Randy-
 
With Worksheets("Sheet1")
.Activate
.Range("A1"). _
currentRegion.AutoFilter Field:=4, _
Criteria1:=Userform1.Listbox1.Value
With.autofilter.Range
.offset(1,0).Resize(.Rows.count-1). _
specialcells(xlVisible).Select
End With
End With
 
Back
Top