Can I write a VBE so that (for example)
If Rows 10:20 are hidden,
then hide Row 9
Does anyone know how I can do this?
Can I write a VBE so that (for example)
If Rows 10:20 are hidden,
then hide Row 9
Does anyone know how I can do this?
I am guessing there is more to the problem?
Hiding a single sheets is as easy as right clicking the tab and clicking hide, what is the value of automating this?
Thanks,
Solus
Please remember the following:
1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.Highlight the code in your post and press the # button in the toolbar.2. Show appreciation to those who have helped you by clickingbelow their posts.
3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.
"Slow is smooth, smooth is fast."
Solus is right. Giving you the answer to your specific question is easy. But I highly doubt it will solve your true problem.
![]()
If Range("A10:A20").EntireRow.Hidden = True Then Range("A9").EntireRow.Hidden = True End If
RG WORKING_3.xlsm
I have a range of cells that pull from a separate sheet. When the row returns a blank, I have code to hide that row.
Between sections of rows there is a gray "divider" row. If everything in the section returns a blank all of the rows in the section will be hidden. If all the whole section is hidden, then I want the divider row to hide as well. I'm attaching my workbook for reference. See the "Tracking" Sheet.
Thank you!
Replace your current HideOnEmpty macro with this one. Much faster. If it works for you feel free to click the star in the bottom left corner.
*Note: The only way I could think of working this was based upon the color of the "grey" line. If that color changes or you choose a different but similar color in the future, it won't work.
![]()
Sub HideOnEmpty() Dim ws As Worksheet: Set ws = Sheets("Tracking") Dim StartRow As Integer Dim Endrow As Long, icell As Long, myCount As Long Dim myRange As Range, rCell As Range Application.ScreenUpdating = False 'unhide all ws.Range("A9:A1000").EntireRow.Hidden = False StartRow = 9 Endrow = ws.Range("C" & Rows.Count).End(xlUp).Row 'Hide emtpy cells For Each rCell In ws.Range("C10:C954") If rCell.Value = "" And rCell.Interior.ColorIndex = xlNone Then rCell.EntireRow.Hidden = True End If Next rCell 'Hide grey bar For icell = 10 To Endrow - 1 If ws.Range("C" & icell).Interior.ColorIndex = 15 Then myCount = ws.Range("C" & icell).Row - (StartRow + 1) Set myRange = ws.Range("C" & StartRow + 1, "C" & icell - 1) If Application.WorksheetFunction.CountBlank(myRange) = myCount Then ws.Range("A" & StartRow).EntireRow.Hidden = True End If StartRow = ws.Range("C" & icell).Row End If Next icell Application.ScreenUpdating = True End Sub
Last edited by stnkynts; 07-22-2013 at 04:16 PM.
This is awesome! Thank you so much!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks