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 / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Hide Columns Based on Condition

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Skornia115 - 05 Jul 2006 18:49 GMT
New to VBA and need help.

I am trying to hide columns based on a condition.  My workbook has
numerous worksheets.  Each worksheet contains data for a specific
"account" and each column within the "account" worksheet has month end
data.  Therefore row 1 of each worksheet contains month-end values and
each row below has various data for that specific "account."
Furthermore, the first worksheet, which basically serves as a "menu",
has a cell with a specific date.  What I would like to do is write a
macro in each worksheet representing an "account" that hides all
columns in the "account" worksheets that have not occurred yet.  (i.e.
If the date on the menu worksheet is 3/31/05,  I would like all columns
that have month-end values exceeding 3/31/05 to be hidden).  Any
suggestions?
Bob Phillips - 05 Jul 2006 23:14 GMT
   For Each sh In Activeworkbook.Worksheets
       With sh
           If sh.Name <> "Menu" Then
               For i = 1 To sh.Cells(1,sh.Columns.Count).End(xlUp).Column
                   If sh.Cells(1,i).Value >
Worksheets("Menu").Range("A1").Value Then
                       Columns(i).Hidden = True
                   End If
               Next i
           End If
       End With
   Next sh

where A1 on Menu is the menu date comparing against

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

> New to VBA and need help.
>
[quoted text clipped - 10 lines]
> that have month-end values exceeding 3/31/05 to be hidden).  Any
> suggestions?
Skornia115 - 05 Jul 2006 23:30 GMT
Forgive my for my ignorance but where do I place this syntax?

> For Each sh In Activeworkbook.Worksheets
>         With sh
[quoted text clipped - 33 lines]
> > that have month-end values exceeding 3/31/05 to be hidden).  Any
> > suggestions?
Skornia115 - 05 Jul 2006 23:30 GMT
Forgive my for my ignorance but where do I place this syntax?

> For Each sh In Activeworkbook.Worksheets
>         With sh
[quoted text clipped - 33 lines]
> > that have month-end values exceeding 3/31/05 to be hidden).  Any
> > suggestions?

Rate this thread:






 
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.