B
Brian
I have a workbook which has one tab (“Shortlist”) with about 150 rows of
data, and a tab (“Longlist”) with about 20,000 rows of data. I need to
be able to select a column in Shortlist and a column in Longlist (which
I would do manually), then do the following:
- for each row in the Longlist column,
- compare the cell in Longlist with the whole column in Shortlist,
- if the cell in Longlist does NOT match any cell in the corresponding
column in Shortlist, hide the row in Longlist,
- go down to the next row.
I am using XL2000 in XP, and I have managed to produce this so far,
adapting code I have found elsewhere.
Sub Hide_Rows()
Dim R As Long
Dim rng As Range
Application.ScreenUpdating = False
If Selection.Rows.Count > 1 Then
Set rng = Selection
Else
Set rng = ActiveSheet.UsedRange.Rows
End If
For R = rng.Rows.count To 1 Step -1
‘If [This is the problem area] Then
rng.Rows(R).EntireRow.Hide
End If
Next R
Application.ScreenUpdating = True
End Sub
I would appreciate any suggestions.
data, and a tab (“Longlist”) with about 20,000 rows of data. I need to
be able to select a column in Shortlist and a column in Longlist (which
I would do manually), then do the following:
- for each row in the Longlist column,
- compare the cell in Longlist with the whole column in Shortlist,
- if the cell in Longlist does NOT match any cell in the corresponding
column in Shortlist, hide the row in Longlist,
- go down to the next row.
I am using XL2000 in XP, and I have managed to produce this so far,
adapting code I have found elsewhere.
Sub Hide_Rows()
Dim R As Long
Dim rng As Range
Application.ScreenUpdating = False
If Selection.Rows.Count > 1 Then
Set rng = Selection
Else
Set rng = ActiveSheet.UsedRange.Rows
End If
For R = rng.Rows.count To 1 Step -1
‘If [This is the problem area] Then
rng.Rows(R).EntireRow.Hide
End If
Next R
Application.ScreenUpdating = True
End Sub
I would appreciate any suggestions.