Userform2 is a listbox filled with project #'s. The selected #'s then fill Column "A" of a sheet called "Project2".
Sheet "DM", column "P" is populated with an unknown amount of different project #'s. These change each week.
I am comparing column "A" from "Project2" with column "P" from "DM". If there is a match, it does nothing, if there is not a match, it hides the entire row.
The code is working,however, it is only matching the last value in column "A" of "Project2" instead of all of the values(I made sure to choose values that do exist in the "DM" sheet).
Sub Project()
UserForm2.Show
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Dim CompareRange As Variant, To_Be_Compared As Variant, x As Variant, y As Variant
Worksheets("DM").Activate
Worksheets("DM").Columns(16).Select
Selection.End(xlDown).Select
Set To_Be_Compared = Worksheets("DM").Range("P1:" & Selection.Address)
Worksheets("Project2").Activate
Worksheets("Project2").Columns(1).Select
Selection.End(xlDown).Select
Set CompareRange = Worksheets("Project2").Range("A1:" & Selection.Address)
Worksheets("DM").Activate
To_Be_Compared.Select
For Each x In Selection
For Each y In CompareRange
If x = y Then
x.EntireRow.Hidden = False
Else
x.EntireRow.Hidden = True
End If
Next y
Next x
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Any help would be appreciated. I am not sure where I am going wrong here.
Bookmarks