Code to Hide / unhide Rows in excel

Nesma Mamdouh

New Member
Joined
Dec 8, 2015
Messages
2
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 :)
 

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,261
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 :)
Hi Nesma,

Try out this code:

Code:
Sub TEST()
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:A" & LastRow).EntireRow.Hidden = Not Range("A1:A" & LastRow).EntireRow.Hidden
End Sub
 

Forum statistics

Threads
1,085,992
Messages
5,387,141
Members
402,045
Latest member
Hidalgo

Some videos you may like

This Week's Hot Topics

Top