Hi all
I have been working a bit at a time on this macro for the past several weeks, and it actually worked (yea me!) Anyway, last week for reasons of its own, it decided to stop working and freeze not only the macro execution, but excel itself, to the point I had to use Ctrl+Alt+Del to break it up. I put in an on error goto with a snappy message to let me know that it didn't work, but it doesn't even do that.
Stepping through the code, this is the place (very near the beginning) that it wants to go berserk:
The purpose is to select records encompassing the past 6 months (give or take), from there it will perform some analysis and formatting to give management basically a dashboard showing performance over the last 6 months from the day it is run.![]()
Sub Macro2() Dim datebreak As Variant datebreak = Now() - 180 Sheets("Data Staging").Select Cells.Select Selection.Delete Shift:=xlUp Sheets("Pivot Table").Select ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh ' ' yada yada yada clickity clickity clickity put in header row ' lrow = Worksheets("Pivot Table").Range("A" & Rows.Count).End(xlUp).Row For i = 4 To lrow If Worksheets("Pivot Table").Range("A" & i).Value >= datebreak Then Worksheets("Pivot Table").Range("A" & i & ":P" & i).Copy _ Worksheets("Data Staging").Range("A" & Rows.Count).End _ (xlUp).Offset(1, 0) End If Next i End Sub
Most of the entire macro (and it is about 14pgs long printed) was created using the macro recorder, then trying to file down the rough edges and get rid of anything that it didn't need. I am sure it is not the most streamlined macro out there, but it has truly been a stretch for me. I am sure there is a better way of getting these records, but it eludes me.
I would appreciate any help or suggestions anyone could provide.
Thanks
Bookmarks