ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox and vba auto filter (https://www.excelbanter.com/excel-programming/317260-listbox-vba-auto-filter.html)

Tom Rudski[_4_]

Listbox and vba auto filter
 
XL2K3 Listbox
A B C D
RG 1 8 9
8P 2 1 3
Total 12

RG 1 8
2P
8P 2 1
7P

The top rows above 'Total' are a List box (filtered).
below 'Total' are rows with value (RG,2P) summing up to the ListBox.
I recorded a macro and copied it into:

Private Sub Worksheet_Change(ByVal Target As Range)
If xx 0 Then
xx = 0
On Error GoTo 0
Exit Sub
End If
xx = 0
On Error Resume Next
Range("E4").Select
Worksheets("sheet 1").ShowAllData
On Error GoTo 0
Range("E4").Select
xx = 1
Selection.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd
' range("C11").Select
End Sub

This works, but the ListBox stays active and the List box filter does not
filter until after I select another cell outside the List box.

Can a List Box be automated like this or do you need to loop through using
'long hand' VBA counts and items....
Any Help appreciated.
TIA




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

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