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 :)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top