+ Reply to Thread
Results 1 to 16 of 16

Populate invoice from database sheet (Attached)

  1. #1
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Smile Populate invoice from database sheet (Attached)

    I have tried for two weeks before finally joining the forum out of desperation; can someone here please help me?

    I am trying to populate an invoice from a list of items in another sheet

    I have two sheets in one workbook, Sheet1 (Invoice) and sheet2 (Database).
    Both sheets have 3 columns, B, C & K with headings (quantity-Description-cost).
    Sheet 1 is a list of 2000 items; each item can be selected by entering a quantity.

    I would like to use a macro that copies the items selected in sheet2 to the first blank row (counting from the top down B14:K2000) to sheet 1.
    Only the selected items would be copied and placed sequentially in sheet1, no blank cells or rows would be copied.

    I have attached a workbook with two macros, everything works just fine if you hit the 'copy rows' macro but it deletes the formulas in the total column, so I would prefer to use the 'copy cells' macro but the items are being copied with blank rows and it will only populate one page where the 'copy rows macro' populates more than one page with header and footer.

    Code below if it helps.

    Thanks for looking, Mayweed.

    Cell macro
    Please Login or Register  to view this content.
    Row macro that adds totals and formats if the page is full

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Mayweed; 08-24-2010 at 06:59 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate invoice from database sheet (Attached)

    I'm not really clear what you are doing.

    I can see the idea of transferring selected items, but why bother with the formulas? Place the formulas in the Invoice and only copy the Qty, Description & item cost
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    You are right, the copy cell macro is doing that but it copies the blanks as well, how can that be fixed?. I put the copy row together so that if the items exceed the page size of 35 it places a new total on the last page.
    I suppose that the copy row macro works just fine but it kills the invoice for manual population after it's been run. The copy cell macro would only populate one page.
    Last edited by Mayweed; 08-19-2010 at 08:06 AM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate invoice from database sheet (Attached)

    This code will transfer selected items to the Invoice, all formulas need entering into the invoice. The coe will not delete them
    Please Login or Register  to view this content.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Populate invoice from database sheet (Attached)

    Just for chuckles, this shows you how you can get the same thing in realtime with no VBA. I've used the empty column A on each sheet to create an index. As you add QTY values in the database, the hidden index changes and the rows indexed will appear instantly on the Invoice sheet.

    I've colored the font in column A white to keep the indexes invisible. Change color temporarily if you want to see the indexes in action.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    Thank you, that works great but if the invoice is populated with more than 35 items the total screws up. Is there any way to auto move the total section down like the 'row' macro does?
    What I'm trying to do is select up to 2000 items and hit print, this will give x pages with headers and footers on each and the Sub total, Vat. & Total, on the last page.

    One new workbook attached with your macro and more items to illustrate my point.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    Jerry Beaucaire',
    Very clever, thanks for that... but again the sub total etc. gets messed up.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate invoice from database sheet (Attached)

    I would add sufficient empty rows to the form, then add code to hide empty rows. I've extended it to Row 1021, just amend it to suit yourself

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    Roy, I just tried your code and it does populate more rows if I create them first but I cant get the total to appear just below the last row. What am I missing?

  10. #10
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    Roy, I just realised the quantity fields were empty for the total rows so please disregard the last comment.

  11. #11
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Smile Re: Populate invoice from database sheet (Attached)

    My thanks to Jerry and Roy who helped with this problem; I decided to use Roy's solution in the end because he replied to both questions with ideas and code that worked perfectly.

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate invoice from database sheet (Attached)

    Shall I mark this Solved?

  13. #13
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    I thought I had marked it as solved but if I haven’t, please go ahead.
    One question... Where do I find the scales icon to rate a reply?

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate invoice from database sheet (Attached)

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  15. #15
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Populate invoice from database sheet (Attached)

    I already done that, any idea where I can rate a users reply with the scales?

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Populate invoice from database sheet (Attached)

    Every post has one in the upper right corner.

+ 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