Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hide and Unhide Rows button

I have this code for a button to hide and Unhide rows (7 to 10) But it
hides everything in my sheet. I just want it to hide just the 4 rows.

Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = True
CommandButton8.Caption = "UnHide"
Else
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = False
CommandButton8.Caption = "Hide"
End If
End Sub

Thanks in advance,

Cheers John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Hide and Unhide Rows button

Try this:

Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Rows("7:10").hidden=true
CommandButton8.Caption = "UnHide"
Else
Rows("7:10").hidden=false
CommandButton8.Caption = "Hide"
End If
End Sub


"FinlandGuy" wrote:

I have this code for a button to hide and Unhide rows (7 to 10) But it
hides everything in my sheet. I just want it to hide just the 4 rows.

Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = True
CommandButton8.Caption = "UnHide"
Else
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = False
CommandButton8.Caption = "Hide"
End If
End Sub

Thanks in advance,

Cheers John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Hide and Unhide Rows button

Try this:
Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Range("7:10").EntireRow.Hidden = True
CommandButton8.Caption = "UnHide"
Else
Range("7:10").EntireRow.Hidden = False
CommandButton8.Caption = "Hide"
End If
End Sub

Regards,
Stefi


€žFinlandGuy€ť ezt Ă*rta:

I have this code for a button to hide and Unhide rows (7 to 10) But it
hides everything in my sheet. I just want it to hide just the 4 rows.

Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = True
CommandButton8.Caption = "UnHide"
Else
Range("7:7,8:8,9:9,10:10").Select
Selection.EntireRow.Hidden = False
CommandButton8.Caption = "Hide"
End If
End Sub

Thanks in advance,

Cheers John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Hide and Unhide Rows button

Hi John, it works fine for me. you can shorten your code with excel 2003

Private Sub CommandButton8_Click()
If CommandButton8.Caption = "Hide" Then
Range("7:10").EntireRow.Hidden = True
CommandButton8.Caption = "UnHide"
Else
Range("7:10").EntireRow.Hidden = False
CommandButton8.Caption = "Hide"
End If
End Sub


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hide and Unhide Rows button

I dont think you displayed your hole message. Please try again. thanks

BR,
John


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hide and Unhide Rows button

Awesom thanks a bunch

Cheers,
John
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Hide and Unhide Rows button

You are welcome! Thanks for the feedback!
Stefi

€žFinlandGuy€ť ezt Ă*rta:

Awesom thanks a bunch

Cheers,
John

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
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
hide or unhide rows with button Bea Excel Discussion (Misc queries) 15 September 19th 07 07:03 PM
Code for button to hide/unhide rows Chris Excel Worksheet Functions 5 March 5th 07 06:15 AM
Command Button to Hide/Unhide Rows Bea Excel Discussion (Misc queries) 4 March 16th 06 03:21 PM
create button that can hide/unhide sheets and hyperlink... Helen Excel Programming 7 November 16th 05 04:03 AM


All times are GMT +1. The time now is 03:39 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"