Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default hide/unhide row macro


I'm new to writing macros and need a little help. I'm trying to write
macro that will hide/unhide different rows within a worksheet. Fo
example, I want to check a box and be able to hide rows 8, 10 and 12
but leave rows 9 and 11 alone. Thanks in advance for your help

--
Checkma
-----------------------------------------------------------------------
Checkman's Profile: http://www.excelforum.com/member.php...fo&userid=1062
View this thread: http://www.excelforum.com/showthread.php?threadid=50346

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default hide/unhide row macro

Put a checkbox from the forms toolbar (not the control toolbox toolbar) on a
worksheet.

Assign it this macro:

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCBX As CheckBox

Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

Set myRng = ActiveSheet.Range("a8,a10,a12")

' If myCBX.Value = xlOn Then
' myRng.EntireRow.Hidden = True
' Else
' myRng.EntireRow.Hidden = False
' End If

myRng.EntireRow.Hidden = myCBX.Value

End Sub

The commented lines may be easier to understand, but they're equivalent to the
last line.

Checkman wrote:

I'm new to writing macros and need a little help. I'm trying to write a
macro that will hide/unhide different rows within a worksheet. For
example, I want to check a box and be able to hide rows 8, 10 and 12,
but leave rows 9 and 11 alone. Thanks in advance for your help!

--
Checkman
------------------------------------------------------------------------
Checkman's Profile: http://www.excelforum.com/member.php...o&userid=10620
View this thread: http://www.excelforum.com/showthread...hreadid=503463


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default hide/unhide row macro

try
Sub ToggleHideColumns()

'Range("a1,c1,g1").EntireColumn.Hidden = Not
Range("a1,c1,g1").EntireColumn.Hidden
Range("a2,a4,a8").EntireRow.Hidden = Not Range("a2,a4,a8").EntireRow.Hidden
End Sub

--
Don Guillett
SalesAid Software

"Checkman" wrote in
message ...

I'm new to writing macros and need a little help. I'm trying to write a
macro that will hide/unhide different rows within a worksheet. For
example, I want to check a box and be able to hide rows 8, 10 and 12,
but leave rows 9 and 11 alone. Thanks in advance for your help!


--
Checkman
------------------------------------------------------------------------
Checkman's Profile:
http://www.excelforum.com/member.php...o&userid=10620
View this thread: http://www.excelforum.com/showthread...hreadid=503463



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default hide/unhide row macro


Thanks Dave and Don!


--
Checkman
------------------------------------------------------------------------
Checkman's Profile: http://www.excelforum.com/member.php...o&userid=10620
View this thread: http://www.excelforum.com/showthread...hreadid=503463

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default hide/unhide row macro

glad to help. you may have to correct the word wrap if you want to use the
column one

--
Don Guillett
SalesAid Software

"Checkman" wrote in
message ...

Thanks Dave and Don!


--
Checkman
------------------------------------------------------------------------
Checkman's Profile:
http://www.excelforum.com/member.php...o&userid=10620
View this thread: http://www.excelforum.com/showthread...hreadid=503463





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
Macro that will unhide then hide rows minka Excel Discussion (Misc queries) 10 October 21st 06 01:37 PM
hide/unhide macro Matt Excel Discussion (Misc queries) 2 April 6th 06 07:24 PM
hide/unhide macro zenahs[_3_] Excel Programming 2 November 10th 05 06:37 PM
Macro that will always hide / unhide next column Kirby[_3_] Excel Programming 2 June 7th 04 10:21 PM
Hide/Unhide Macro bug Dave[_28_] Excel Programming 1 September 4th 03 06:26 PM


All times are GMT +1. The time now is 01:32 AM.

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

About Us

"It's about Microsoft Excel"