+ Reply to Thread
Results 1 to 10 of 10

Macro to add rows depending on the size of data volume and create new workbook

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Macro to add rows depending on the size of data volume and create new workbook

    There are 2 sheets Main File and DBR Report.

    Main File is where the data is pasted.Since data is generated for 2 clients (code is AA and US) it contains 2 buttons.

    DBR Report contains Template into which data is pasted into specific columns from Main File.

    In short, when either of the buttons are clicked, data from Main File is pasted into specific columns in the Template.

    When AA button is clicked, data is pasted into the template and column Q is updated with code AA.
    Same thing happens when US button is clicked, only column Q is updated with code US.

    Below is the code that does this partly -

    Please Login or Register  to view this content.
    There are 3 columns in the template which are already updated with certain data

    Column A
    FR:
    TO:

    Column B
    BA
    BA

    Column Q
    AA
    AA

    Looking for few additions to the above code as below :

    1)Depending on the volume of data in the Main File the macro should add
    or deduct rows from the template format.

    2)Columns A, B and Q should be duplicated one below the other depending
    on the volume of data in the Main File.

    3)Macro should create an individual workbook of DBR Report sheet
    (where the template is)

    4)The new workbook should be named as AA_REACC_Draft_20Apr,
    the sheet tab should also reflect as AA_REACC_Draft_20Apr.

    5)Since the name contains date, macro should rename the workbook as
    well as the sheet tab with date when the macro is run.
    Ex :
    a)When macro is run on 21Apr,workbook and sheet tab
    should be named as AA_REACC_Draft_21Apr
    b)When macro is run on 30Apr, workbook and sheet tab
    should be named as AA_REACC_Draft_30Apr

    6)The new workbook will be saved where the macro is kept.

    The above addition should be achieved when AA or US buttons are clicked.
    (Any Idea for achieving point 5 is welcome)

    Attaching sample sheet with few explanations.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Macro to add rows depending on the size of data volume and create new workbook

    If you start with your template to have 2 rows initially then this will do most of what you have requested. Unfortunately you cannot name a Workbook without saving it (To my knowledge)

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: Macro to add rows depending on the size of data volume and create new workbook

    Should the above code be pasted over the original code.

    I tried, when I clicked on the button got below error

    Compile error :
    Sub or function not defined

  4. #4
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Macro to add rows depending on the size of data volume and create new workbook

    In my code there is a line that says
    Please Login or Register  to view this content.
    This is where your code should go. (you need to define the variable colQ btw!)

    EDIT: I just realised you are passing it colQ so it doesn't need defining! The only other thing wrong that I can see is with the save file, Both are saved as AA...... I am assuming the US button should save it as US.... But hopefully that should be an easy fix for you...if not let me know!
    Last edited by ARowbot; 04-16-2015 at 08:50 AM.

  5. #5
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: Macro to add rows depending on the size of data volume and create new workbook

    I'm new to macro so PLEASE help me out here.

    Pasted macro as suggested above. But unable to define the variable colQ

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Macro to add rows depending on the size of data volume and create new workbook

    Apologies, I edited my post just as you were posting!

    EDIT: I just realised you are passing it colQ so it doesn't need defining! The only other thing wrong that I can see is with the save file, Both are saved as AA...... I am assuming the US button should save it as US.... But hopefully that should be an easy fix for you...if not let me know!
    The latest code you have pasted seems to work for me! (But call it test instead of bimmy since that's what the buttons are calling!)

  7. #7
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: Macro to add rows depending on the size of data volume and create new workbook

    I removed the below code

    Please Login or Register  to view this content.
    And it works partly.

    Can you HELP me out with the buttons. (If you can attach the final sample sheet it would be GR8)

    EDIT :
    When clicked on Button AA it should do all the above activity and also update column Q with AA. Similary for Button US
    Last edited by bimmy80; 04-16-2015 at 09:39 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Macro to add rows depending on the size of data volume and create new workbook

    All Problems should now be fixed. Enjoy:

    EDIT: It currently saves it to my dropbox which obviously you don't have access to: so you will need to change that bit of the code
    Attached Files Attached Files
    Last edited by ARowbot; 04-16-2015 at 10:36 AM.

  9. #9
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: Macro to add rows depending on the size of data volume and create new workbook

    Exactly what I'm looking for.

    THANKS A TONNE... Especially for your patience.

  10. #10
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Macro to add rows depending on the size of data volume and create new workbook

    You're welcome. If all the problems are now solved then please mark the thread as solved using thread tools at the top.

    And If I have helped then any reputation you may wish to give would also be appreciated

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 05-18-2023, 07:18 PM
  2. Create a macro which creates a workbook and copies rows to it
    By jmatthews in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2013, 01:09 PM
  3. Create a workbook depending on value in A
    By fabdav in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2012, 06:47 AM
  4. Size a cell depending on a TextBox size.
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2007, 04:50 PM
  5. Size of Workbook(columns/rows/data)
    By Browner in forum Excel General
    Replies: 3
    Last Post: 07-13-2006, 01:15 PM

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