Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2016, 07:15 AM
carlandtina02 carlandtina02 is offline unhide hidden row Windows XP unhide hidden row Office 2010 64bit
Novice
unhide hidden row
 
Join Date: Mar 2016
Posts: 11
carlandtina02 is on a distinguished road
Default unhide hidden row

Hi Folks,



Can anyone help with this?

The current code hides rows E33:E58 and unhides one row at a time if the previous row is populated and works great, but now i need it to do the same to another set of rows too (rows E61:E86), i thought i would be able to copy the code and just change the cell address but no joy! any help would be great )

Thanks in advance


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("E33:E58")) Is Nothing Then
Application.ScreenUpdating = False
Dim LR As Long
LR = Range("E58").End(xlUp).Row
If Not IsEmpty(Range("E58")) Then
Range("E33:E58").EntireRow.Hidden = False
Exit Sub
End If
If Range("E58").EntireRow.Hidden = False Then
Range("E" & LR + 2, "E58").EntireRow.Hidden = True
Else
If Not IsEmpty(Target.Offset(1, 0)) Then
Target.End(xlDown).Offset(1, 0).EntireRow.Hidden = False
Else
Target.Offset(1, 0).EntireRow.Hidden = False
End If
End If
End If

End Sub] 

Last edited by Pecoflyer; 03-11-2016 at 01:09 AM. Reason: Added code tags
Reply With Quote
  #2  
Old 03-10-2016, 08:01 PM
Philb1 Philb1 is offline unhide hidden row Windows 10 unhide hidden row Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2016
Location: Auckland
Posts: 43
Philb1 is on a distinguished road
Default

Try this code. If it works as it was for one range then this should work for two ranges.
I can sort of see what you're trying to do. Try it & see if it's what you want.
Post a sample workbook if you need further assistance
Cheers

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim LR As Long

On Error GoTo ExitOut

If Not Intersect(Target, Range("E33:E58")) Is Nothing Then
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
    
    LR = Range("E58").End(xlUp).Row
    
    If Not IsEmpty(Range("E58")) Then
        Range("E33:E58").EntireRow.Hidden = False
    Exit Sub
    End If
    
    If Range("E58").EntireRow.Hidden = False Then
        Range("E" & LR + 2, "E58").EntireRow.Hidden = True
    Else
        If Not IsEmpty(Target.Offset(1, 0)) Then
            Target.End(xlDown).Offset(1, 0).EntireRow.Hidden = False
        Else
            Target.Offset(1, 0).EntireRow.Hidden = False
        End If
    End If
    GoTo ExitOut
    
ElseIf Not Intersect(Target, Range("E61:E86")) Is Nothing Then
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    LR = Range("E86").End(xlUp).Row
    
    If Not IsEmpty(Range("E86")) Then
        Range("E61:E86").EntireRow.Hidden = False
    Exit Sub
    End If
    
    If Range("E86").EntireRow.Hidden = False Then
        Range("E" & LR + 2, "E86").EntireRow.Hidden = True
    Else
        If Not IsEmpty(Target.Offset(1, 0)) Then
            Target.End(xlDown).Offset(1, 0).EntireRow.Hidden = False
        Else
            Target.Offset(1, 0).EntireRow.Hidden = False
        End If
    End If
    GoTo ExitOut
End If

ExitOut:
With Application
    .EnableEvents = True
    .ScreenUpdating = True
End With
Exit Sub
End Sub
Reply With Quote
  #3  
Old 03-11-2016, 04:52 AM
carlandtina02 carlandtina02 is offline unhide hidden row Windows XP unhide hidden row Office 2010 64bit
Novice
unhide hidden row
 
Join Date: Mar 2016
Posts: 11
carlandtina02 is on a distinguished road
Default

Hi Philb1,

That works great, just one thing though, the rows only hide upon data entry, is there a condition to hide them before data entry? (I've attached a workbook for reference).

Thanks for your help, it's much apreciated

Regards

Carlandtina02
Attached Files
File Type: xlsm Sample1.xlsm (224.6 KB, 11 views)
Reply With Quote
  #4  
Old 03-11-2016, 03:08 PM
Philb1 Philb1 is offline unhide hidden row Windows 10 unhide hidden row Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2016
Location: Auckland
Posts: 43
Philb1 is on a distinguished road
Default

I carlandtina
I don't fully understand what you need. Do you mean you want the lines E33:E58 and E61:E86 hidden? So when you look at the sheet those lines are not visible? If E58 or E86 is empty the lines for that table are hidden? I'm not sure how things are supposed to work lol. If you can tell me in laymans terms I'd appreciate it
Cheers
Phil
Reply With Quote
  #5  
Old 03-11-2016, 03:29 PM
carlandtina02 carlandtina02 is offline unhide hidden row Windows XP unhide hidden row Office 2010 64bit
Novice
unhide hidden row
 
Join Date: Mar 2016
Posts: 11
carlandtina02 is on a distinguished road
Default

Hi Phil,

Haha, sorry its probably me not explaining properly!

What i want to happen is for rows 33 and 61 to always be visible with the rest hidden, then when one of the above rows is populated it will unhide the next row ready for populating.

Hope this helps

Thanks
Carl
Reply With Quote
  #6  
Old 03-11-2016, 03:33 PM
carlandtina02 carlandtina02 is offline unhide hidden row Windows XP unhide hidden row Office 2010 64bit
Novice
unhide hidden row
 
Join Date: Mar 2016
Posts: 11
carlandtina02 is on a distinguished road
Default

Haha,

Phil i forgot to mention that i want this to happen after i press the clear report button!

Carl
Reply With Quote
  #7  
Old 03-11-2016, 08:06 PM
Philb1 Philb1 is offline unhide hidden row Windows 10 unhide hidden row Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2016
Location: Auckland
Posts: 43
Philb1 is on a distinguished road
Default

Hi Carl

I changed the ClearReport macro from just deleting the contents of the service report sheet to include the hiding of the rows.
I changed the worksheet change macro by removing & changing some of the code.

I hope it's what you're after
Cheers
Phil
Attached Files
File Type: xlsm Sample1 (1).xlsm (226.5 KB, 12 views)
Reply With Quote
  #8  
Old 03-14-2016, 02:26 PM
carlandtina02 carlandtina02 is offline unhide hidden row Windows XP unhide hidden row Office 2010 64bit
Novice
unhide hidden row
 
Join Date: Mar 2016
Posts: 11
carlandtina02 is on a distinguished road
Default

Hi Phil,

That works great now, thanks very much for your help, you're a star!!!


Regards
Carl
Reply With Quote
Reply

Tags
vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
A row that will not UNHIDE MaineLady Excel 0 11-23-2014 01:15 PM
unhide hidden row VBA to keep hidden rows hidden when filtering tectonicseer Excel Programming 1 07-27-2014 11:54 AM
unhide hidden row Unhide Projects in VBA Editor Greg S. Excel Programming 2 07-24-2013 07:31 AM
Hide/Unhide pictures maloneb PowerPoint 1 01-18-2012 03:34 PM
unhide hidden row Hidden style applied over already-hidden text. christie Word 1 08-17-2011 09:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft