Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do you hide/un-hide the grid lines | Excel Discussion (Misc queries) | |||
Want to Hide columns in spreadsheet but NOT hide data in chart. | Charts and Charting in Excel | |||
Specify which rows to NOT hide, and have excel hide the rest | Excel Programming | |||
Hide And Un-hide Excel Toolbars | Excel Programming | |||
How do I hide a worksheet in Excel and use a password to un-hide . | Excel Discussion (Misc queries) |