• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select two months, hide the others

govi

Member
Hi,


I'm creating a timeline.

I want to select two months in cell A1 and B1, the two months selected and the months in between have to bee visible the other ones have to be hidden

Is this possible?


I have included a example file:

http://dl.dropbox.com/u/12607909/example.xlsx


I could really use some help on this one,

Thanks! govi
 
Govi

A few comments if I may


Use dates instead of text when dealing with dates

eg: In row 5 you have dates for January and then Text for Feb to Dec

I Changed E5 to

E5: =DATE(2011,1,COLUMN()-COLUMN($D$5))

then copy across

Then copy and paste as values


In A1 & B1 change them to Both dates as well and format as MMM

Enter values in A1 and B1 as 1/4/2011 and 1/5/2011 etc


Then you can use some VBA like

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Or Target.Address = "$B$1" Then
Application.ScreenUpdating = False
For Each c In Range("E5:NE5")
If Month(c.Value) < Month([A1].Value) Or Month(c.Value) > Month([B1].Value) Then
c.EntireColumn.Hidden = True
Else
c.EntireColumn.Hidden = False
End If
Next
Application.ScreenUpdating = False
End If
End Sub
[/pre]

Copy the above to the Code page for the page with your data on it "Blad1"
 
Back
Top