Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2004, 08:53 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hide Row with VBA

Hi,

I'm wondering if there is a function in VBA Excel to hide row or unhide rows.

Thanks in advance


 
Old November 24th, 2004, 09:08 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes: set the Hidden property of the required Range object to True, eg:

Code:
ActiveSheet.Rows("5:5").Hidden=True
to hide the 5th row in the current worksheet
 
Old November 24th, 2004, 09:11 AM
Authorized User
 
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered
Default

Selection.EntireRow.Hidden = True

will hide the rows and

Selection.EntireRow.Hidden = False

will display them..

simple routine to use them could be..


Sub Hide()
RowShow 4, 4, True
End Sub

Sub Show()
RowShow 4, 4, False
End Sub

Sub RowShow(myRow1 As Double, myRow2 As Double, bStatus As Boolean)
If bStatus = True Then bStatus = False Else bStatus = True
Rows(myRow1 & ":" & myRow2).Select
Selection.EntireRow.Hidden = bStatus
End Sub

Where myRow1 and myRow2 are the row numbers, so if you want to hide a single you (ie 4) you enter the same number twice (4,4), or you enter the start and end point for a number of rows (ie 5 to 10)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide a Row in a FormView Control frosty ASP.NET 2.0 Basics 5 July 14th, 2006 03:07 PM
show/hide row(s) eugz Beginning PHP 0 March 19th, 2006 10:10 PM
How to hide VBA code james gold Excel VBA 12 November 14th, 2005 10:59 AM
Hide table with VBA mmcdonal Access VBA 5 June 24th, 2005 10:13 AM
Hide VBA code when forwarding macro sh333384 Excel VBA 7 September 2nd, 2004 10:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.