+ Reply to Thread
Results 1 to 21 of 21

Auto populate

  1. #1
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Auto populate

    I am trying to create a document register in a workbook which auto-populates from a seperate workbook containing several different documents within different tabs. Multiple users will complete the documents and all contain similar information (although in different locations), ideally I would like to add a button on each document which once pressed copies the relevent information into the first available blank row in the register.

    Hope I have explained the problem clearly, thanks for your help.
    Last edited by Dave H9; 03-15-2011 at 03:45 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: Auto populate

    It shouldn't be too difficult to do.

    However. there is a certain element of vagueness about your question.

    It would help if you provided a sample register and a sample documen with some typical data in it. You need to indicate what data is copied, from where (tab/cells) and to where (gain, tab/cells)

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    TMShucks

    Thank you for the reply. I have attached (hopefully) two workbooks.

    "Example register" is the one I need to auto-populate.
    "Example documents" is the source file and has two tabs with simplified examples of data which will be added by multiple users.

    We would probably produce 20+ documents a day which would gradually produce a monthly register of the details so the macro would need to populate the first available blank row each time a new document is created.

    Thank you very much for your help

    Regards

    Dave

    Example register.xls

    Example documents.xls

  4. #4
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    Has anyone any suggestions please?

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

    Re: Auto populate

    It would be easier to have a hidden sheet in the document that summarised the inputs to one row, then simply copy that row.

    I would remove the Merged Cells though
    Hope that helps.

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

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    11-16-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Auto populate

    I have code I have written that allows users to click a button that opens an existing work book, looks for the next blank cell and writes the information.

    I'll make it more readable and post it here ASAP

  7. #7
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    royUK - excellent suggestion thank you.

    HardyRexion - Thank you, that button is the key element of what I am trying to acheive.

    Thank you both for your contribution.

  8. #8
    Registered User
    Join Date
    11-16-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Auto populate

    Ok, here is a stripped down version that shows where you need to enter your specific information.

    Please Login or Register  to view this content.
    This code works fine for me.

    Obviously just put the routine's name in the click event of the button

    Please Login or Register  to view this content.
    Last edited by HardyRexion; 03-14-2011 at 05:06 AM.

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

    Re: Auto populate

    I haven't had time to check this. Summarise the inputs to Sheet2 of the document then close & save
    This code prompts to select the workbook then copies the range A1 to A10 to the main workbook. Adjust the range reference to suit
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    Thank you both. I am a bit of a novice on code so I'll take a little while to apply this to my problem. I'll get back once I've done that.

    Thanks again

    Regards

  11. #11
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    HandyRexion,

    How do I specify the range to copy?

    royUK,

    I can't get this to work as my source has multiple tabs

    Please Login or Register  to view this content.
    is it possible to allow the tab selection when the "file to zip" is selected and I can hide the source data within each tab?

    Thanks again.

  12. #12
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    OK nearly got HardyRexion's code working for me. I have added the following -

    Please Login or Register  to view this content.
    and altered
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    When I hit the button to launch the code I can see the correct info is copied to the clipboard, also the correct workbook opens and correctly selects the first blank cell in column A, however the error Number 438 is generated. I'm guessing the paste I added is causing this. How do I get the paste function to work?

    As I said I am a novice so your patience and help is greatly appreciated.

    Regards

    Dave

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto populate

    If you appreciate the contribution of several users to the same register, you'd better use:

    Please Login or Register  to view this content.



  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: Auto populate

    Please Login or Register  to view this content.
    strToWrite is a String so you can't use Copy with it like that.

    For my code

    Which sheet are you summarising the data to ?

  15. #15
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    snb, what does your code do? is it a log file?

    Here is the code as modified, I have got it to work as required but could do with knowing how to specify a specific worksheet on the destination workbook -

    Please Login or Register  to view this content.
    The copy function seems to work but not sure if it breaches standard practice! Also I had to use the paste special function to avoid just pasting cell references.

    royUK,
    With your code I am summarising on several different sheets within a file called permits then trying to copy that to the destination (register).

    Thank you all again for you contributions, this has been a great introduction to VBA for me.

    Regards

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

    Re: Auto populate

    That code to find the next empty row is really inefficient. It only opens the specific document, I thought you had several possible documents to import from

    If it's one workbook with multiple users consider using a template workbook (*.xlt) that a user opens, completes then saves it. Having multiple sheets for completion in one workbook just makes maintenance of the task complicated
    Last edited by royUK; 03-14-2011 at 10:48 AM.

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto populate

    snb, what does your code do? is it a log file?
    Yes, that's a logfile (the simplest, fastest and most robust).
    Just try it.
    If you want to use a csv-file:

    Please Login or Register  to view this content.

  18. #18
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    royUK,

    The source documents are all contained within one workbook on several worksheets. The code in my last post seems to be working well. Given this would you recomend any alterations to improve efficiency.

    snb,

    Thank you I will give it a go.

    Again a big thank you to all for taking the time to help and humouring a novice.

  19. #19
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    snb,

    I can't seem to get your code to work. I have put it in a new module within the document register(.xls). Also I have changed the file path to reflect my system and created the file "register.txt". Closing my workbookdoes not populate the text file. Had a read in the help file and tried using your code in a class module instead, stillnot working . Any suggestions?

    Thank you

  20. #20
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto populate

    Cfr. the attachment.

    Open it and close it: macros enabled.
    Look for C:\register.csv
    Attached Files Attached Files

  21. #21
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Auto populate

    Thanks snb, I will use that.

+ 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