Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2015, 06:19 AM
NullVBA NullVBA is offline Hide / unhide Rows Windows 7 64bit Hide / unhide Rows Office 2007
Novice
Hide / unhide Rows
 
Join Date: Dec 2015
Posts: 2
NullVBA is on a distinguished road
Default Hide / unhide Rows

Good Afternoon,

i am little bit new to VBA code.



I am working on an excel sheet with different contract Articles, I need to have a code when i double click on the Article heading it hides all its sub Articles, and double click again it unhides them. the problem is i need to repeat this code to all the Articles i have which would be like 100 Article heading. All the codes i find online is fixing the rows to hide like A3:A9 !. i need a criteria to stop the hide maybe until it reaches a blank space.

it is easier for me if i just double click on the Cell that contains the Article name.

Any idea ??? Please help
Reply With Quote
  #2  
Old 12-08-2015, 09:20 AM
charlesdh charlesdh is offline Hide / unhide Rows Windows 7 32bit Hide / unhide Rows Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

Can you provide a workbook? It will make it easier for the members.
Also if you posted on another forum let us know.
Reply With Quote
  #3  
Old 12-08-2015, 06:10 PM
charlesdh charlesdh is offline Hide / unhide Rows Windows 7 32bit Hide / unhide Rows Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

HI,

Try this code in the worksheet code module.
When you double click in "A1" the code will hide all of the rows to the "1st" empty row.
If you need to do this several time then you will need a different code.
That's why I asked for file to look at. In the file indicate where you need the "Hide" action to take place.

When you double click on range "A1" again it will unhide the rows.

Code:
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim i As Long
i = Range("A1").End(xlDown).Row
If Target.Column = 1 Then
    Cancel = True
    If Range("A" & Target.Row + 1).Rows.Hidden Then
        Range("A:A").Rows.Hidden = False
    Else
        Range("A" & Target.Row + 1 & ":A" & i + 1).Rows.Hidden = True
    End If
End If
End Sub
Reply With Quote
  #4  
Old 12-09-2015, 02:32 AM
NullVBA NullVBA is offline Hide / unhide Rows Windows 7 64bit Hide / unhide Rows Office 2007
Novice
Hide / unhide Rows
 
Join Date: Dec 2015
Posts: 2
NullVBA is on a distinguished road
Default

I thought I did yesterday, probably wasn't a successful post. Find attached a similar excel sheet. I want to be able to hide/ un hide the sun articles by double clicking of their main article.

Yes I did post in other forum but didn't receive a reply yet.

Thank you.
Attached Files
File Type: xlsx Hide - unhide Rows.xlsx (8.6 KB, 17 views)

Last edited by NullVBA; 12-10-2015 at 01:37 AM.
Reply With Quote
  #5  
Old 12-09-2015, 05:10 AM
macropod's Avatar
macropod macropod is offline Hide / unhide Rows Windows 7 64bit Hide / unhide Rows Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by NullVBA View Post
Yes I did post in other forum but didn't receive a reply yet.
Since you've cross-posted on other forums, please provide the relevant links - plus links to this forum on those other forums as well.

This is all part of the standard cross-posting etiquette, for which please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Unhide Text Based on Drop Down Selection gw1500se Word 3 02-19-2015 12:17 PM
Hide / unhide Rows Hide/Unhide a Block of Text Based on Choice Selection inquirer Word VBA 7 09-22-2014 04:41 PM
Hide / unhide Rows VBA Code Needed that will Hide / Unhide a row when used with a "Check Box" barryoffshore Excel Programming 4 06-23-2014 05:07 AM
Hide/Unhide pictures maloneb PowerPoint 1 01-18-2012 03:34 PM
Hide / unhide Rows Unhide and Re-hide in Excel 2003 thorgal67 Excel 1 07-16-2009 07:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:08 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