#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default < then hide

Hi Jacob,

I'm having some issues with the code. To test it, if I put the same date in
g and q (with h,r blank), in row 1, it works. If I move to row 2, with
nothing or text (xx in both) in row one, it hides row 3. If I put a non
matching date in row one, it also hides row three.

I'm confused and have no idea why it won't work. The hiding of row three is
really throwing me off.

FYI,
The data I'm running this through is structured like this.
A compilation of 15 source sheets, merged into one document. rows g and q
are originally calendar control 11.0, and h and r are data validation cells
from a list.


row 1: header for source (don't want to hide) but is blank as data is in A1,
but centered across selection
row 2-3: text (can hide - but is in cell a* but also centered across
selection)
row 4: text in cell g or q which is a header for the column, will be the
same and could be hidden.
row 5-37: rows g and q are formatted as dates (actually if I click format
cell, says custom and then mm/dd/yyyy.)
Then rows 1:37 are repeated, 15 times. I'm cool putting in the work to
specify each range (especially as this expands to 25+ in the future).

Thanks,
Anders

"Jacob Skaria" wrote:

Anders

Now the requirement is a bit more clearer. Comments included below for
better understanding...Try and feedback

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

'Check whether G or Q has a date (to ignore headers)
If IsDate(.Cells(i).Value) = True Or _
IsDate(rRangePrimary.Cells(i).Value) = True Then

'If cells G and H match Q and R, I want to hide them
If .Cells(i).Value = rRangePrimary.Cells(i).Value And _
.Cells(i, 2).Value = rRangePrimary.Cells(i, 2).Value Then _
Rows(i).Hidden = True

End If

Next i
End With

End Sub

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you hide/un-hide the grid lines ED Excel Discussion (Misc queries) 4 February 26th 13 03:22 PM
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
Specify which rows to NOT hide, and have excel hide the rest Mo2 Excel Programming 0 April 25th 07 03:44 AM
Hide And Un-hide Excel Toolbars Jim333[_4_] Excel Programming 3 July 2nd 05 08:00 PM
How do I hide a worksheet in Excel and use a password to un-hide . Dchung Excel Discussion (Misc queries) 3 December 2nd 04 06:24 AM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"