Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

hide/unhide row macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Checkman - 20 Jan 2006 19:14 GMT
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
Dave Peterson - 20 Jan 2006 19:43 GMT
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.

> 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
[quoted text clipped - 6 lines]
> Checkman's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=10620
> View this thread: http://www.excelforum.com/showthread.php?threadid=503463

Signature

Dave Peterson

Don Guillett - 20 Jan 2006 19:59 GMT
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

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

>
> 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 - 20 Jan 2006 21:09 GMT
Thanks Dave and Don!

Signature

Checkman

Don Guillett - 20 Jan 2006 21:46 GMT
glad to help. you may have to correct the word wrap if you want to use the
column one

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

>
> Thanks Dave and Don!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.