ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro (https://www.excelbanter.com/excel-discussion-misc-queries/342425-macro.html)

kartk

Macro
 
Hi,

I have an requirement in excel to Expand & collapse rows for a certain range.
Below is the code written for the same,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [H5]) Is Nothing Then
[6:10].Rows.Hidden = True

End If

If Not Intersect(Target, [E:E]) Is Nothing Then
[6:10].Rows.Hidden = False
End If

End Sub

However if an user insert a new row i want to include the additional row dynamically to the existing range. Please help

Jim Cone[_2_]

Macro
 
Name the range and use the range in your code.

Me.Range("MyRows").Rows.Hidden = True

--
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html
editorial review of special sort excel add-in (30 ways to sort)





"kartk"
wrote in message
...

Hi,

I have an requirement in excel to Expand & collapse rows for a certain
range.
Below is the code written for the same,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [H5]) Is Nothing Then
[6:10].Rows.Hidden = True

'End If

If Not Intersect(Target, [E:E]) Is Nothing Then
[6:10].Rows.Hidden = False
End If
End Sub

However if an user insert a new row i want to include the additional row
dynamically to the existing range. Please help
--
kartk




kartk

Quote:

Originally Posted by Jim Cone[_2_] (Post 1207821)
Name the range and use the range in your code.

Me.Range("MyRows").Rows.Hidden = True

--
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html
editorial review of special sort excel add-in (30 ways to sort)





"kartk"
wrote in message
...

Hi,

I have an requirement in excel to Expand & collapse rows for a certain
range.
Below is the code written for the same,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [H5]) Is Nothing Then
[6:10].Rows.Hidden = True

'End If

If Not Intersect(Target, [E:E]) Is Nothing Then
[6:10].Rows.Hidden = False
End If
End Sub

However if an user insert a new row i want to include the additional row
dynamically to the existing range. Please help
--
kartk

Hi Jim,

Thanks a lot....


All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com