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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,214,832
Messages
6,121,844
Members
449,051
Latest member
excelquestion515

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