+ Reply to Thread
Results 1 to 23 of 23

copy data of invoice from userform to two sheets at the same time

  1. #1
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    copy data of invoice from userform to two sheets at the same time

    hello
    I have userform when I fill data then copy to sheet "invoice" what I would to be coping data to sheet "data" this is like archive invoices , so I put expected result in sheet data and every invoice is filling in sheet " invoice" should copy to bottom the old data of invoice has already copy earlier
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    It's not that hard to do, I'll download the file and let you know as soon as I can work it out
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: copy data of invoice from userform to two sheets at the same time

    Once the invoice is filled you can copy the information to the Data sheet.

    Delete the merged cells you have in the data sheet.
    You can format the columns in the Data sheet accordingly.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: copy data of invoice from userform to two sheets at the same time

    hi, @keepellah take your time

  5. #5
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: copy data of invoice from userform to two sheets at the same time

    hi @ daves actually I tested your code but it gives me error about merged cells in this line
    HTML Code: 
    but I think cancelled all of merged cells , may you check my updating file ,please?
    Attached Files Attached Files

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    davesexecl code has a problem.
    Thre range you copy is not alwa\ssy B16 to G30 you need to find the last filled row

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    daveexcel, the last row should be calculated but the problem is the last row in data is a merged cell.
    I hate people using merged cells, but that can be fixed.
    delete the last two rows in DATA and rebuild them after copying but NO merging would be my idea.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    Apart from that the code the OP has posted is sloppy.
    Needs tailoring but your macro works if you delete the last two data rows, also you need to format the data after copying that's not done either.
    Hope the OP learns from this too, that's the goal, help others build better macros

  9. #9
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: copy data of invoice from userform to two sheets at the same time

    also you need to format the data after copying that's not done either.
    @ keepellah you're right even if I cancels emerged cells there is a problem not show value of invoice total
    you can see the result in attached file
    Attached Files Attached Files

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: copy data of invoice from userform to two sheets at the same time

    Quote Originally Posted by Keebellah View Post
    davesexecl code has a problem.
    Thre range you copy is not alwa\ssy B16 to G30 you need to find the last filled row
    If the other cells have no data, what difference does that make? the code finds the last filled cell in the data sheet to insert the other information.

    Did you not see in my post that merged cells need to be deleted in the data sheet?

    Just work on your own stuff.

  11. #11
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: copy data of invoice from userform to two sheets at the same time

    Purely an observation, normally an invoice data recording system would not normally store the final summations just the data that is necessary to perform that function.
    This ensures that simple table format is easier to configure and use.
    torachan.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    You work on your own stuff.
    Someone has long toes here, sorry to have pointed it out

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905
    Quote Originally Posted by ABDELFATTA View Post
    @ keepellah you're right even if I cancels emerged cells there is a problem not show value of invoice total
    you can see the result in attached file
    I’ll leave this to mr Dave, he knows what he’s doing

  14. #14
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: copy data of invoice from userform to two sheets at the same time

    thanks @ keebellah for your sharing ,I appreciate your assistance , advice and opinion
    so I have to wait maybe any member helps me

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    This is my modification on Mr D's code.
    You must add a check to the command button to verify that all fields in a row are completed before saving.
    The subtotal is set in a formula after copying that data
    Might need fine-tuning but this works so far

    I also ordened your tab order in the userform, so when you press tab it goes to the next field and not up and down like it was
    Attached Files Attached Files

  16. #16
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: copy data of invoice from userform to two sheets at the same time

    Quote Originally Posted by Keebellah View Post
    Someone has long toes here, sorry to have pointed it out
    "Work on your own stuff" , was supposed to mean supply your own answer.

    You were not pointing anything out that I did not take into consideration but it is nice that you thought you needed to speak for the OP.

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    it's okay, let's just hope the OP can use the ideas he's gotten; that's the main goal here anyway

  18. #18
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: copy data of invoice from userform to two sheets at the same time

    @ keepellah I apprecite your mod the code and trying to solve my problem , but there is missing I would show the total row is each invoice alone not together and breaking among invoices not sucking you can see what I mean in attached file
    Attached Files Attached Files
    Last edited by ABDELFATTA; 01-14-2021 at 02:33 AM.

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    You should explain things more clearly when asking.
    I'm sure that can be doen. will look into it.
    I still advice you to add code to check if the invoice is complete before you press the command button, else the data will not copy correctly and you will have to add many exceptions when copying

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    The caption on your button says Add or Update Invoice, the code by Dave only adds, not updates.
    Will this be your next question?

  21. #21
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: copy data of invoice from userform to two sheets at the same time

    Refer to post# 11.
    you are developing a data storage nightmare
    torachan.

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    @torachan: with that I agree

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: copy data of invoice from userform to two sheets at the same time

    You idea is indeed a nightmare.
    I changed the DATA table to an actual table with a subtotal row.
    This link will help you understand tables (Listobjects) https://www.thespreadsheetguru.com/b...0with%20Tables
    The file now adds the data to this table and the subtotal is the bottom row.
    If you filter the invoice or customer the total is according to what you see.
    If you don't want it this way, well, you've got enough code to practice with and make the necessary changes

    Happy coding
    Attached Files Attached Files

+ 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. [SOLVED] Required vba code copy data sheets to new workbook & retn to old sheet userform
    By sbvaram in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-21-2020, 12:55 AM
  2. Copy Data from Database to Input Sheets Using Userform Selection
    By Rudidw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2020, 11:59 AM
  3. userform which can add data to invoice and sale sheet both
    By relief12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2017, 09:33 AM
  4. Choose Invoice Number from a userform combobox and copy data to invoice output
    By djemy1975* in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-07-2016, 06:02 AM
  5. Saving Invoice where next time I open file the Invoice Number increases by 1
    By domgee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-22-2013, 03:03 PM
  6. [SOLVED] Excel VBA- copy data from userform to sheet 1 with a new row each time
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2013, 09:54 AM
  7. Copy data from userform to sheet, on a new row each time
    By parm1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2009, 08:55 AM

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