Results 1 to 3 of 3

Thread: Month wise calender macro

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    25
    Rep Power
    0

    Month wise calender macro

    I am trying to prepare month wise calender. So my spreadsheet has 12 tabs for each month. On top of each tab i want to place a macro which should hide all active tabs except for the month we want to view.

    For eg. we are viewing Sept. 2013. At this point of time only sept. 2013 tab is visible.

    On top left Aug, 2013 and top right Oct. 2013 is written. So when a user click on Aug 2013, All tabs should go invisible ONLY August 2013 remain visible. Same way when user click on Oct. 2013, All tabs should go invisible ONLY October 2013 remain visible.

    Please see the attached excel. Thanks in advanceCalender.xlsx

  2. #2
    Junior Member
    Join Date
    Aug 2013
    Posts
    6
    Rep Power
    0
    Hi,

    ALT+F11 to open VB editor. Double click 'ThisWorkbook' and paste the code below in on the right. Close VB editor.
    Click a worksheet month in Q4 to Q15.
    Note you must now save your workbook as a macro enabled workbook with a .XLSM extension.


    Code:
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
    Dim x As Long
    If Not Intersect(Target, Sh.Range("Q4:Q15")) Is Nothing Then
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        For x = 1 To Worksheets.Count
        Sheets(x).Visible = True
        Next
        For x = 1 To Worksheets.Count
        If UCase(Left(Sheets(x).Name, 3)) <> UCase(Left(Target.Value, 3)) Then
            Sheets(x).Visible = False
        End If
        Next
        Range(Target.Address).Select
        Application.EnableEvents = True
         Application.ScreenUpdating = True
    End If
    End Sub
    Last edited by Mike H; 11-11-2013 at 04:37 PM.

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    25
    Rep Power
    0
    Thank you Mike..!
    Last edited by Admin; 11-12-2013 at 10:22 AM.

Similar Threads

  1. MACRO CODE TO KNOW MONTH and QUATER
    By Prabhu in forum Excel Help
    Replies: 4
    Last Post: 09-27-2013, 10:16 PM
  2. Macro to change month and year on all sheet
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-15-2013, 05:58 PM
  3. Absolute Calender Program!
    By Preeti Verma in forum Excel Help
    Replies: 1
    Last Post: 11-06-2012, 01:19 PM
  4. Request for Calender
    By sanjeevi888 in forum Excel Help
    Replies: 1
    Last Post: 08-12-2012, 10:55 AM
  5. Splittting Data Into Different Worksheets Column Wise In VBA
    By rajeshd@live.in in forum Excel Help
    Replies: 1
    Last Post: 01-21-2012, 04:45 PM

Posting Permissions

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