Below is my data in sheet "Sheet1"
IDJan-13Feb-13Mar-13Apr-13Apr-13May-13Jun-13Jul-13Aug-13Sep-13
A112162646102050402515
A224182426202020202525
A348153018301010102045
A416512010405020303015
I wish the data should be visible only for latest six months. for example, if the current month for Oct-13,
IDApr-13May-13Jun-13Jul-13Aug-13Sep-13
A1102050402515
A2202020202525
A3301010102045
A4405020303015
and if the current month is Nov-13, the values for Oct-13 will be visible.
IDMay-13Jun-13Jul-13Aug-13Sep-13Oct-13
A1205040251510
A2202020252525
A3101010204535
A4502030301530
remaining columns should be hidden. If there is no data in Oct-13 the current month view should be same as Sep-13. I have month row is filled till 2014 and each row has formula based on another sheet "Sheet2". If I add data for oct-13 in "Sheet2", the data will be visible for Oct-13 column in "Sheet1" otherwise it will be blank. It will be helpful if someone help me how to make this dynamic using excel VBA.
Thanks in advance.
Assuming my header is in row 2 and i am picking up the current date by today() function. I am checking the current date with the month mentioned in the same column. today() function is to be moved to next cell when there are values in that column. otherwise it remains in the same column. Here is my workaround for the above task. i want this needs to be simplified and working.
Sub Workbook_Open()
Cells(A1).Select
Selection.End(xlToRight).Select
r = Selection.Row
c = Selection.Column
If Month(Cells(r, c)) = Month(Cells(r + 1, c)) + 1 Then
ActiveCell.Offset(0, -7).Select
Range(Selection, Cells(ActiveCell.Row, 2)).Select
Selection.Hide
Cells(r, c).Select
ActiveCell.Offset(1, 1).Select
Range(Selection, Cells(ActiveCell.Row, Selection.End(xlToRight).Select)).Select
Selection.Hide
Else
Cells(r, c).Content.Cut
ActiveCell.Offset(0, 1).Select
Selection.Paste
End If
End Sub
IDJan-13Feb-13Mar-13Apr-13Apr-13May-13Jun-13Jul-13Aug-13Sep-13
A112162646102050402515
A224182426202020202525
A348153018301010102045
A416512010405020303015
I wish the data should be visible only for latest six months. for example, if the current month for Oct-13,
IDApr-13May-13Jun-13Jul-13Aug-13Sep-13
A1102050402515
A2202020202525
A3301010102045
A4405020303015
and if the current month is Nov-13, the values for Oct-13 will be visible.
IDMay-13Jun-13Jul-13Aug-13Sep-13Oct-13
A1205040251510
A2202020252525
A3101010204535
A4502030301530
remaining columns should be hidden. If there is no data in Oct-13 the current month view should be same as Sep-13. I have month row is filled till 2014 and each row has formula based on another sheet "Sheet2". If I add data for oct-13 in "Sheet2", the data will be visible for Oct-13 column in "Sheet1" otherwise it will be blank. It will be helpful if someone help me how to make this dynamic using excel VBA.
Thanks in advance.
Assuming my header is in row 2 and i am picking up the current date by today() function. I am checking the current date with the month mentioned in the same column. today() function is to be moved to next cell when there are values in that column. otherwise it remains in the same column. Here is my workaround for the above task. i want this needs to be simplified and working.
Sub Workbook_Open()
Cells(A1).Select
Selection.End(xlToRight).Select
r = Selection.Row
c = Selection.Column
If Month(Cells(r, c)) = Month(Cells(r + 1, c)) + 1 Then
ActiveCell.Offset(0, -7).Select
Range(Selection, Cells(ActiveCell.Row, 2)).Select
Selection.Hide
Cells(r, c).Select
ActiveCell.Offset(1, 1).Select
Range(Selection, Cells(ActiveCell.Row, Selection.End(xlToRight).Select)).Select
Selection.Hide
Else
Cells(r, c).Content.Cut
ActiveCell.Offset(0, 1).Select
Selection.Paste
End If
End Sub