+ Reply to Thread
Results 1 to 17 of 17

Macro needed to create new worksheets and feed through specific data

  1. #1
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Macro needed to create new worksheets and feed through specific data

    Hi,

    I have attached 2 spreadsheets - Test1 & Test2 to assist with my problem.

    Test1 is where I currently hold information about accounts. However, I have come across the problem if new accounts are created.

    Is there a macro I can use that will extract the data from Test2 and create a new worksheet in Test1 containg all the inforamtion I need? I will then also need the new worksheet to be renamed after 'Code_2'.

    In the future there is potential for several dozen new accounts that will needed to be added to Test1 so this macro can't be specific for just the example I have illustrated in Test2.

    Any help would be much appreciated.

    Thanks
    Attached Files Attached Files

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

    Re: Macro needed to create new worksheets and feed through specific data

    The data in columns A to E are exactly the same in both records. So there should be 1 sheet created with 2 entries in rows 14 onwards, right?
    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]

  3. #3
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Hi Arlette - that's correct.

  4. #4
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Hi Arlette,

    Have you had time to review my problem above?

    Thanks,

    Eoghan

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

    Re: Macro needed to create new worksheets and feed through specific data

    Sorry for the delay.

    Try this code -
    Please Login or Register  to view this content.
    Put it in a standard module.

  6. #6
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Hi Arlette,

    Thanks very much for taking your time to do that. The data from Columns F, G & H from Test2 are appearing in Row 11 in Test1 - it should appear in Row 15. It also seems as though it is pulling through the data for Asset_1 and not Asset_2 as well. Is it possible to achieve this? Thanks

  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 needed to create new worksheets and feed through specific data

    In your sample file that you sent, the 1st 2 sheets didnt have headers in row 14. The macro makes a copy of the 1st sheet so since there were no headers, it started the pasting from row 11. If you have headers in your 1st sheet, when it makes the copy, the data will get pasted in row 15 as required.

    Once the first issue is solved, the 2nd will get done too.

  8. #8
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Hi Arlette,

    Thanks for your quick response. I've copied the headers into row 14 of sheet 1 but the 2nd issue hasnt been solved - asset_1 is the only one pulling through.

  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 needed to create new worksheets and feed through specific data

    Updated code -
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Excellent Arlette - thanks for that!

  11. #11
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Macro needed to create new worksheets and feed through specific data

    Hello,

    Is it possible for you attach the workbook with the working macros?

    Thank you

  12. #12
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    Please find attached
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Macro needed to create new worksheets and feed through specific data

    Hello,

    There arn't any macros in them..

  14. #14
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Macro needed to create new worksheets and feed through specific data

    I think you need to add them yourself. Do you know how to do this?

  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 needed to create new worksheets and feed through specific data

    Naja,

    You need to take the macro i provided in post 9 and put it in Test2.xls through these steps -

    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  16. #16
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Macro needed to create new worksheets and feed through specific data

    Thank you Arlette

  17. #17
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Macro needed to create new worksheets and feed through specific data

    Hello Arlette,

    I did exactly that and it is written ''subscript out of range'' whwen i run the macro

+ 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