Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Command buttons linked to moving rows

I have a worksheet where I need to quickly display hidden rows (so as to
€˜drill-down to more detailed information) and then re-hide the rows when
necessary.

I have set up command buttons linked to the following macros to do this:
_____

Private Sub CommandButton11_Click()

Rows("88:88").Select
Selection.EntireRow.Hidden = False
Range("A88").Select
End Sub

Private Sub CommandButton12_Click()

Rows("88").Select
Selection.EntireRow.Hidden = True
End Sub
_____

This works perfectly well until I insert or delete rows above the command
buttons. When I do that, the buttons now hide the wrong rows.

Is it possible to lock the macro so that it will only affect the desired
rows, wherever they are in the worksheet?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Command buttons linked to moving rows



Name a cell in the row and use that name in your code.
Also, you do not need two buttons or two sets of code...

Range("TheCell").EntireRow.Hidden = Not Range("TheCell").EntireRow.Hidden
--
Jim Cone
Portland, Oregon USA




"steal_92"
wrote in message
I have a worksheet where I need to quickly display hidden rows (so as to
€˜drill-down to more detailed information) and then re-hide the rows when
necessary.
I have set up command buttons linked to the following macros to do this:
_____

Private Sub CommandButton11_Click()
Rows("88:88").Select
Selection.EntireRow.Hidden = False
Range("A88").Select
End Sub

Private Sub CommandButton12_Click()
Rows("88").Select
Selection.EntireRow.Hidden = True
End Sub
_____

This works perfectly well until I insert or delete rows above the command
buttons. When I do that, the buttons now hide the wrong rows.
Is it possible to lock the macro so that it will only affect the desired
rows, wherever they are in the worksheet?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Command buttons linked to moving rows

Thanks for you response Jim, that really helps

"Jim Cone" wrote:



Name a cell in the row and use that name in your code.
Also, you do not need two buttons or two sets of code...

Range("TheCell").EntireRow.Hidden = Not Range("TheCell").EntireRow.Hidden
--
Jim Cone
Portland, Oregon USA




"steal_92"
wrote in message
I have a worksheet where I need to quickly display hidden rows (so as to
€˜drill-down to more detailed information) and then re-hide the rows when
necessary.
I have set up command buttons linked to the following macros to do this:
_____

Private Sub CommandButton11_Click()
Rows("88:88").Select
Selection.EntireRow.Hidden = False
Range("A88").Select
End Sub

Private Sub CommandButton12_Click()
Rows("88").Select
Selection.EntireRow.Hidden = True
End Sub
_____

This works perfectly well until I insert or delete rows above the command
buttons. When I do that, the buttons now hide the wrong rows.
Is it possible to lock the macro so that it will only affect the desired
rows, wherever they are in the worksheet?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command buttons aussiegirlone Excel Discussion (Misc queries) 2 January 8th 09 09:09 AM
Command Buttons Hoyas07 Excel Discussion (Misc queries) 2 February 11th 08 03:42 PM
Command Buttons msals22 Excel Discussion (Misc queries) 1 June 22nd 06 01:33 AM
Help with command buttons Danno Excel Worksheet Functions 1 October 7th 05 10:32 PM
command buttons Natalie Excel Worksheet Functions 1 March 7th 05 01:45 PM


All times are GMT +1. The time now is 05:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"