+ Reply to Thread
Results 1 to 33 of 33

Macro to update Aging Report

  1. #1
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Thumbs up Macro to update Aging Report

    Hello,

    I need your help in creating a Macro for preparing a Aging Report.

    In the sample sheet I have Raw Data sheet and in that it has to look for Close time column and if it is empty it need to copy the data in another sheet named Aging Data (As in sample sheet).

    I need the Pivot table as shown in the sample data and in that I have added Column H & I using today () function & below code manually. Please help me to automate it.

    Please Login or Register  to view this content.
    Note: The data is not constant and vary.

    Thanks in advance for your help!!

    Regards,
    Humac
    Last edited by humacdeep; 12-01-2011 at 12:04 PM.

  2. #2
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Aging Report

    Bump no response!!

  3. #3
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Hi,

    I got the code to copy the data to another sheet if Close Time Column is empty. Please help me in automating the Report in Pivot Tables Sheet.

    Please Login or Register  to view this content.
    Thanks in advance for your help!!

    Regards,
    Humac

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Do you need the 2 calculations to be done in the pivot sheet itself? Or how about doing it in the Aging data tab and then pulling it over to the pivot? Or we could use a calculated field for the pivot (which is going to be a lil complicated).
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Hi Arlette,

    Thanks for your reply!!

    I am ok to have the calculation done in Aging Report and pulling it over to Pivot but the final result should look like the table in Pivot Tables (Sample Sheet).

    Regards,
    Humac

  6. #6
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Hi Arlette,

    Did you get a chance to look in to this?

    Regards,
    Humac

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Will look into it today.

  8. #8
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks Arlette!!

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    I have modified your copy code as well. This is an end-to-end code which involves - filtering and copying data, creating the pivot, adding the 2 calculation fields. On 2nd thoughts, i retained the calculations in the pivot tab itself as it was not giving proper values if included in the Aging Data tab.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks Arlette!!

    I have tried the code and the result is not correct. I hope it is preparing the pivot table using both Aging Data & as well as Pivot Data.

    In the real case senario we will have only Raw Data and using that it need to create the Pivot Table. Is it possible to modify the code accordingly?

    Regards,
    Humac

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    I can change it no doubt. However, as per your instructions, i had done the pivot on the Aging Data as the pivot reflects how many days the lines are aged right?

    What do you mean by -
    I hope it is preparing the pivot table using both Aging Data & as well as Pivot Data.

  12. #12
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Apologize if my earlier request is not clear. I will have the Raw Data sheet and from that it need to prepare the final Pivot Table with Aging (No. of days the lines are aged).


    If you run the Code in the attached sample, it is giving result as 2 under URGENT for the date 22-Jun instead of giving 1. I thought while preparing the Pivot_Tables Sheet is it taking data from Pivot Tables Sheet & Raw Data Sheet as well, so it might be calculating as 2 instead of 1.
    Regards,
    Humac

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Actually the pivot tables sheet only contains the pivot. There is no data in there. So the pivot is taking the data from the aging data tab. The reason you are seeing 2 in the pivot and not 1 is because there would have been data existing in the Aging data tab before you ran the macro. Once you ran the macro, the data got added at the end. If you want, i can have the Aging data cleared before the fresh data is inputted from the Raw data tab. Would this work?

  14. #14
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    ok.... Is it possible to get the Pivot_Tables sheets with Pivot & Aging Data directly from Raw Data Sheet using this Macro?

    If this code needs Data from Pivot Tables Sheets to prepare the Pivot_Tables sheet then I need to first prepare the data manually in Pivot Tables sheet. I am looking for a Automated report from the raw data.

    Regards,
    Humac

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    You actually dont need to prepare the data in the Pivot Tables sheet. It will automatically take the data from the sheet you want. So is the following fine ? -
    - Do not clear the aging data before putting in fresh data.
    - Point the pivot table to take the data from the Raw data tab.

    May i ask the purpose of populating the Aging data tab if you are not using it for the pivot?

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Use this updated code -
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks Arlette, the code is working fine but if possible I want the following modifications.

    1. Can the Macro create the Aging Data & Pivot_Tables when I run the Macro? (Current code is throwing error if Aging Report is is not there, it is creating Pivot_Tables Sheet) or

    2. Can it update the same Aging Data & Pivot_Table Sheets when ever I run the Macro? (Current code is throwing 1004 error when I run the code for the second time)

    Please Login or Register  to view this content.
    3. I want same dates to be Grouped in Pivot Table, will it be possible?

    Regards,
    Humac..

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Quote Originally Posted by humacdeep View Post
    1. Can the Macro create the Aging Data & Pivot_Tables when I run the Macro? (Current code is throwing error if Aging Report is is not there, it is creating Pivot_Tables Sheet) or
    The macro considers that the "Aging Data" tab is already present with headers. If required, this can be created when the macro is running.

    2. Can it update the same Aging Data & Pivot_Table Sheets when ever I run the Macro? (Current code is throwing 1004 error when I run the code for the second time)

    Please Login or Register  to view this content.
    Are you running the code with the "Pivot_Tables" sheet already present? The code will also create a separate "Pivot_Tables" sheet each time the code runs.
    3. I want same dates to be Grouped in Pivot Table, will it be possible?
    What kind of grouping, maybe you can explain some more.

  19. #19
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Please change the code to create the Aging Data Sheet with Headers.

    What kind of grouping, maybe you can explain some more.
    If there are 5 rows with same dates, I want to Group all of them in to single row in Pivot Table using group option (as in sample data)

    Regards,
    Humac
    Last edited by humacdeep; 11-30-2011 at 04:12 PM.

  20. #20
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Use this revised code. It will check if the Aging Data tab is already present. If it is, it will clear it up of all data. If not, it will insert the sheet and the header.
    Please Login or Register  to view this content.
    I didnt find any sample for the grouping. If you can attach a file, i will be able to work on it for you.

  21. #21
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks Arlette!!! Its working like a charm .

    I have attached two Sheets (one is sample sheet & other is generated using Macro). You can see the Grouped dates in Sample sheet but where as it is showing the different rows for the same dates.

    Regards,
    Humac
    Attached Files Attached Files

  22. #22
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Ok..i understood the problem. What have you done in the Aging Sample to avoid the "time" from appearing in the Request time field? If i remove the time, then i will be able to group it. Actually the pivot itself will group it.

  23. #23
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Actually I didn't remove the time in Aging Sample. In the Pivot I have right clicked on date and clicked on Group & I have grouped using days, then automatically it has changed in to the format in the Aging Sample.

  24. #24
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Find the updated code here:
    Please Login or Register  to view this content.

  25. #25
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Perfect!! its working as desired..

    Is it possible to have the Header format applied to Column H & I as others columns?

    Regards,
    Humac..

  26. #26
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Add this code above the last "End With" in your code -
    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks a LOT for all your help!!

  28. #28
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    You are welcome

  29. #29
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Arlette,

    I have run this in my orginal Data and I am getting Correct Aging Data but the Data in the Pivot_Tables is not correct, I hope it is pulling data from RawData instead of Aging Data to get the Pivot Table

    I have attached the report. Please have a check.

    Regards,
    Humac
    Last edited by humacdeep; 12-01-2011 at 01:35 PM.

  30. #30
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    Yes. The reason for the discrepancy is that the "Raw Data" tab also includes those where the Close Time is not empty. I noticed that your pivot is referencing the "Aging Data" tab, but you asked me to reference the pivot to the "Raw Data" tab. The raw data contains all the data and will not give you a true picture of the aging items.

  31. #31
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Got it and I have changed the code & got the result.

    If possible the formating which we did using below code needs to be changed. I have changed all the urgencies to Low and now the pivot table is generated as desired, but due to fixed formating we used for Column H & I its not moving to last two rows of the pivot table. Is it possible to change the code?

    Please Login or Register  to view this content.
    I have attached the sample spread sheet.

    Sorry for keep on asking Questions.

    Regards,
    Humac

  32. #32
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to update Aging Report

    I have changed the code. Find updated code here :
    Please Login or Register  to view this content.

  33. #33
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro to update Aging Report

    Thanks, its working!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1