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 / August 2007

Tip: Looking for answers? Try searching our database.

Hide rows using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
buzzandbeyond - 20 Aug 2007 15:05 GMT
Hi,

I am trying to hide rows with a specific value.

In my sheet I have three columns:
Date - The manually inputted date
Today - 1 Month - 'TODAY() -31' (this column will be hidden)
In Range? -  an IF statement to say "HIDE" or SHOW" (this column will
be hidden)

I am looking to hide all the rows where Hide shows in the In Range?
column.  I would also like this to run on opening the document

Any advice is gratefully received as my vba skills are almost non
existent.

cheers
Dave
Michael - 20 Aug 2007 15:54 GMT
Try this:

Sub Hidemyrows()
Dim iLastRow as Integer

iLastRow= Range("A65536").end(xlup).row

For i=1 to iLastRow

If Cells(i,3).value ="Hide" then
Cells(i,3).Entirerow.hidden =true
End If

Next i

End Sub

Signature

If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.

> Hi,
>
[quoted text clipped - 14 lines]
> cheers
> Dave
Bob Phillips - 20 Aug 2007 15:56 GMT
Private Sub Workbook_Open()
Const TEST_COLUMN As String = "A"    '<=== change to suit
Dim i As Long
Dim iLastRow As Long

   With ActiveSheet

       iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
       For i = 1 To iLastRow 'iLastRow to 1 Step -1
           .Rows(i).Hidden = (.Cells(i, TEST_COLUMN).Offset(0, 2).Value =
"HIDE")
       Next i
   End With

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hi,
>
[quoted text clipped - 14 lines]
> cheers
> Dave
 
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.