Macro to build a daily trend list

  • Hello forum,


    I've been playing with a problem but need some help for those that are interested in a teaser. I've recorded macros and attempted writing very basic code but I'm sure someone out there will have a compact solution with smooth code. My goal is to achieve a macro that will perform a laborious routine of copying, pasting and formatting, etc...


    In a nut shell I have 2 worksheets, worksheet A consists of a list of company names ranging from anything from 5 to 30 that have attributes attached to each name (consisting of 3 columns). This list is generated and compiled by a daily report and run externally. The idea is to build a 5 day history trend overview of this data that is collected each day into worksheet B, which represents the entity and its associated value in column 3 (X).


    This means that on each day I need to rebuild the list (worksheet B) consisting of the relevant entities and its associated X value from column 3 based on the daily data output from worksheet A (which also needs to be suitably formatted). Therefore, I'm asking for help with the best approach in using the cleanest logic without getting bogged down. The main things I need to bear in mind are:


    • Entities in the 5 day trend (worksheet B) that have data more than 5 days (without any new additions from the daily generation of Worksheet B) are subsequently removed from the list;
    • New entities that have either not been on the daily generation (worksheet A) for more than 5 days or are completely unique to be subsequently added to the list (worksheet B);
    • Obviously entities that are already on the worksheet B that are less than 5 days to be updated with daily values of X;
    • The list to be suitably formatted by listing the trend overview eventually in alphabetical order.



    Worksheet B on 23/06


    Worksheet B
    EntityComments
    Abba
    AD
    Danish
    EFG
    Future
    Danish
    General
    Global
    Jazz
    Scotland
    Screen
    Terra
    UV






    Genaration of Worksheet A on 24/06

    Worksheet A daily generation
    EntityX
    Multi
    Banca
    Danish
    USA
    Belgium
    Future
    Scotland
    General







    Subsequent Worksheet B on 24/06

    Worksheet B
    EntityComments
    AD
    Banca
    Belgium
    Danish
    EFG
    Future
    GG
    General
    Global
    Jazz
    Multi
    Scotland
    Screen
    UV
    USA






    The macro recorder and tweaking can do the insertion and deletion of columns along with the use of pasting VLOOKUP formulas, but deleting and inserting based on dynamic rows with the above criteria I'm short of ideas and have run into trouble. I have no knowledge of Loops, Until, Do, etc... and was hoping for someone to put me out of my mysery and give me some good sound code to solve this issue.


    Many thanks in advance for anyone to provide a solution or at least push me in the right direction.




    [ATTACH=CONFIG]40204[/ATTACH][ATTACH=CONFIG]40206[/ATTACH]

  • Re: Macro to build a daily trend list


    Hi Amsterdam,


    As i have seen your requirement is very normal requirement is MIS development. First how you are managing your datasheet?


    Are you keeping your data sheet in excel or any database something like access or SQL server.


    What you need to do is convery your excel sheet data to database format to new excel sheet.


    From that database sheet you can create pivot table , or you can use the database to write VBA code via ADO or formulas.


    this will make your life very easy for different months and years to Manage this one single program.



    Best of Luck


    Suresh
    Microsoft excel Developer
    Mumbai

  • Re: Macro to build a daily trend list


    Hello Suresh,
    Thanks for the feedback. First of all I agree with you about trying to enhance the MIS. However, that is not an option hence the request for the VBA mechanics to overcome bad interfacing. So anyone out there that can come up with a slick work around perhaps would be much appreciated?

  • Re: Macro to build a daily trend list


    Welcome to Ozgrid.


    One sample workbook is worth a thousand screenshots and is more helpful to those on the forum assisting in developing solutions.


    To get the most precise answers, it is best to upload a sample workbook (sensitive data scrubbed/removed) that shows a few manually created examples of the desired results.
    The structure and data types of the workbook must exactly match that of the real workbook. Include in the workbook a clear and explicit explanation of all requirements.The sample workbook only needs to contain enough data to illustrate the need to aid with developing the solution.


    [COLOR="navy"]How to edit your post or thread title or upload an attachment[/COLOR]


    1. Click the EDIT POST in the gray band immediately below your post
    2. Click Go Advanced
    3. Edit the post or thread title
    4. To upload: scroll down to Manage Attachments -- use ZIP compression if necessary to meet file size limitations


    You might also consider posting in the Hire Help section for a fully developed solution.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!