Macro for last 12 rolling months

hildaraquel

New Member
Joined
Dec 7, 2016
Messages
2
How do I write a macro to show the rows for the last 12 rolling months and hide others ? Column A is listing dates formatted "Oct 2015, Sep 2015, etc."
I appreciate the help.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Your post is a bit short on information.
Assuming:
- the dates start in row 2 in descending order,
- each date occupies only one row, and
- there are no totals to be shown at the bottom of the data
then :-
Code:
Sub HideRows()
Dim rng As Range
Cells.EntireRow.Hidden = False
Set rng = Intersect(Range(Cells(14, 1), Cells(Rows.Count, Columns.Count)), _
     ActiveSheet.UsedRange)
If Not rng Is Nothing Then rng.EntireRow.Hidden = True
End Sub
 
Upvote 0
Thanks for the reply. Sorry about the lack of info.
The data I want to hide starts from line 6 -29. There is a total I want to show in line 30 (which is merged with line 31, not sure if this is important)
Ops, is not in descending order, is ascending.
 
Upvote 0

Forum statistics

Threads
1,213,581
Messages
6,114,461
Members
448,573
Latest member
BEDE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top