Sure! Here is an image of my userform with the listbox :
Sans titre.PNG
The red circle is the objects I want to KEEP! Those objects.text can be found in another workbook always in the first column. When the objects are not in the ListBox2 then I want to HIDE the entire row.
Here is my code, it works BUT it takes literally 10 minutes to execute... :
Dim ws As Worksheet, wbthis As Workbook, wbtarget As Workbook, wbtarget1 As Workbook, i As Integer, a As Integer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
If UserForm2.CheckBox3 = True Then
Set wbtarget = Workbooks.Open(UserForm2.TextBox3.Text)
wbtarget.Activate
For Each Object In UserForm2.ListBox2.List
For Each ws In wbtarget.Worksheets
For i = 400 To 18 Step -1
ws.Cells(i, 1).EntireRow.Hidden = False
If ws.Cells(i, 1).Value = Object Then
ws.Cells(i, 1).Interior.ColorIndex = 8
Else
End If
Next i
Next ws
Next Object
For Each ws In wbtarget.Worksheets
For i = 400 To 18 Step -1
If ws.Cells(i, 1).Interior.ColorIndex = 8 Then
Else
ws.Cells(i, 1).EntireRow.Hidden = True
End If
Next i
With ws.Columns(1)
.Interior.ColorIndex = 0
End With
Next ws
wbtarget.Close
End If
wbtarget.Save
wbtarget.Close
Set wbtarget = Nothing
End If
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
Bookmarks