< then hide
This code seems to have redundant part, but give it try.
Sub Compare2ShtsTest()
Dim shPrimary As Worksheet
Dim shSecondary As Worksheet
Dim rRangePrimary As Range
Dim rRangeSecondary As Range
Dim strPrompt As String
Dim I As Long
Set rRangePrimary = Range("G1:H536")
Set rRangeSecondary = Range("Q1:R536")
Set shPrimary = rRangePrimary.Parent
Set shSecondary = rRangeSecondary.Parent
With rRangeSecondary
For I = 1 To .Rows.Count
Select Case I
Case 1, 39, 78
Case Else
If shSecondary.Cells(I, "G") = .Cells(I, "Q") _
And shSecondary.Cells(I, "H") = .Cells(I, "R") Then
.Rows(I).Hidden = True
Else
.Rows(I).Hidden = False
End If
End Select
Next I
End With
End Sub
Keiji
Anders wrote:
Jacob and Rick
As I look at my original code - I'm not sure it's doing what I want it to.
It seems to be skipping some cells and killing some I want to see. Maybe you
have something better?
Recap - for a set range (rows 2-38, 40-77 etc (rows 1,39,78 are headers I
would like to exclude from the process if possible)) IF cells G and H match Q
and R, I want to hide them. This leaves all of the exceptions visible. If I
can leave the headers, it tells me the file reference to where the exception
is found. BTW, the data in G and Q are dates, and H and R are text.
Eternally grateful.
Anders
"Jacob Skaria" wrote:
Do you mean...
For i = 1 To .Rows.Count
If .Cells(i).Value < rRangePrimary.Cells(i).Value Then Rows(i).hidden = true
Next i
If this post helps click Yes
---------------
Jacob Skaria
"Anders" wrote:
Hi All,
I have this sub (below) working if I change the
.cells(i) to cells(i).Interior.ColorIndex = 3
but I don't want to color it red if <, I want to hide it. cells(i).hidden
= true doesn't work.
Any help is greatly appreciated!
TIA,
Anders
Sub Compare2Shts()
Dim rRangePrimary As Range
Dim rRangeSecondary As Range
Dim strPrompt As String
Set rRangePrimary = Range("g1:h536")
Set rRangeSecondary = Range("q1:r536")
With rRangeSecondary
For i = 1 To .Rows.Count
If .Cells(i).Value < rRangePrimary.Cells(i).Value Then
.Cells(i).Hidden = True
End If
Next i
End With
End Sub
|