+ Reply to Thread
Results 1 to 2 of 2

Hide Columns automatically based on date

  1. #1
    Registered User
    Join Date
    02-28-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    2

    Hide Columns automatically based on date

    Dear all,

    I have a problem where I want to hide columns automatically when the date of respective columns have expired. If today is 27-Feb-2015 then tomorrow when I reopen my excel that is on 28-Feb-2015 then the columns A:F should hide given A:F were assigned to specific date. Report.xls

    Will it be possible that basic formatting of A:F should also replicate every time when previous columns go into hiding?

    Thank you.

  2. #2
    Registered User
    Join Date
    02-28-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    2

    Re: Hide Columns automatically based on date

    Can someone help me with better syntax,

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim x As Integer
    x = DateTime.Now - Range("D1").Value


    If x >= 1 Then
    Columns("A:F").EntireColumn.Hidden = True
    Else
    Columns("A:F").EntireColumn.Hidden = False
    End If

    Dim y As Integer
    y = Now - Range("J1").Value

    If y >= 1 Then
    Columns("G:L").EntireColumn.Hidden = True
    Else
    Columns("G:L").EntireColumn.Hidden = False
    End If


    Dim Z As Integer
    Z = Now - Range("P1").Value

    If Z >= 1 Then
    Columns("M:R").EntireColumn.Hidden = True
    Else
    Columns("M:R").EntireColumn.Hidden = False
    End If

    Dim x1 As Integer
    x1 = Now - Range("V1").Value

    If x1 >= 1 Then
    Columns("S:X").EntireColumn.Hidden = True
    Else
    Columns("S:X").EntireColumn.Hidden = False
    End If

    Dim y1 As Integer
    y1 = Now - Range("AB1").Value

    If y1 >= 1 Then
    Columns("Y:AD").EntireColumn.Hidden = True
    Else
    Columns("Y:AD").EntireColumn.Hidden = False
    End If


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hide Columns automatically based on year month(YYYY-mm)
    By Jeevhoney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2014, 12:53 AM
  2. Automatically Hide/Unhide Columns Based Dropdown List
    By Kapil.gour in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-27-2012, 07:39 AM
  3. Hide Columns automatically based on date
    By chrisjc19 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2011, 03:32 PM
  4. How do I automatically hide columns in a worksheet based on a cell value?
    By dkhedkar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-04-2005, 09:06 PM
  5. Replies: 0
    Last Post: 03-04-2005, 02:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1