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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,524
Office Version
  1. 365
Platform
  1. Windows
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

hildaraquel

New Member
Joined
Dec 7, 2016
Messages
2
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,196,007
Messages
6,012,825
Members
441,731
Latest member
jonceramic

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
Top