Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i'm looking for a way to create a button in excell that can be placed within
a spreadsheet to control the visiblity of a fixed number of rows. i currently have the following code in place: Private Sub CommandButton1_Click() Dim myRng As Range Set myRng = Me.Range("a2:a10") myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden) End Sub Private Sub CommandButton2_Click() Dim myRng As Range Set myRng = Me.Range("a12:a20") myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden) End Sub I am not VB savvy in the slightest sense and thankfully found this code online, but I ran into a problem once a row is inserted between rows containing the command button. Example: Row 1 has Command Button 1 that controls the hiding/unhiding of rows 2-10 Row 11 has a Command Button 2 that controls the hiding/unhiding of rows 12-20 I insert a row above Row 11 (Command Button 2 shifts along with the row, which is ideal), but by doing so the range in the VB code does not adjust to the downward shift, causing Command Button 2's code to pertain to the wrong range now that the button is in Row 12. Is there a way to create a hide/unhide button with coding that adjusts it's range after it's commanding button is shifted into a different row? - cheetah |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Enabling option „Format rows“ to hide/unhide rows using VBA-code? | Excel Discussion (Misc queries) | |||
VB Code to hide and unhide rows | Excel Discussion (Misc queries) | |||
VB Code to hide and unhide rows | Excel Programming | |||
Hide Rows (Current Date) / Unhide Rows | Excel Programming | |||
Code for button to hide/unhide rows | Excel Worksheet Functions |