+ Reply to Thread
Results 1 to 28 of 28

VBA code to import pick'em picks into master sheet

  1. #1
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    VBA code to import pick'em picks into master sheet

    I've created two spreadsheets used for a friendly workplace college pick'em. One spreadsheet is sent out to everyone to send back with their picks and the other is the master where all the picks are compiled. In the past I've opened each person's pick file and copy and pasted their picks in the the master. I'd like to see if some VBA code could make this a lot simpler. I've attached my two spreadsheets (Updated: deleted attachments see lower posts for attachments).

    I would like the code to prompt me to tell it what the master file is and what the weekly pick file is (and after importing one set of picks ask me for another pick file until complete). What I struggle with is how to get the code to match the person's name in the pick file to the master file and paste their picks in that row.

    The code should find the person's name in the weekly pick file (Z2) and find the matching row of data in the master (somewhere in Column A starting in row 3). Once it is found copy their picks in the weekly pick file (AA2:AN2) and paste on the approriate row in columns B-O. Would also like to copy their tie breaker scores in their weekly picks (AO2 & AP2) into the appropriate row in the masters in column R & T respectively.

    Few notes: There will always be 14 games that are picked and there will always be two games scores used for tiebreakers. The weekly pick will always have the same setup and sheet names. The master file sheet name will change each week (Week 2, Week3, etc.) so some option to change the code each week would be nice.

    I appreciate any help anyone would be willing to give. Thanks in advance. -Chad
    Last edited by chadwick140; 08-26-2013 at 08:54 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi chadwick140

    I'd be willing to play with this but I don't know how to approach it when the Games in the Weekly Picks aren't the same Games as in the Master File. What am I missing?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Sorry should have made them match but I've been "enhancing" the pick sheet this year and just pulled an old sheet from last year for the master. They will match when I finalize it for the first week of the season. Hope that helps you, it shouldn't affect the needed code to copy and paste. Thanks for your time. -Chad

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    Ok...perhaps another will look at this with you. I'll not write the Code and publish it without testing. I'm unable to test with your attached files. Sorry...

  5. #5
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Content deleted by poster. Incorrect information.
    Last edited by chadwick140; 08-24-2013 at 08:06 PM. Reason: had wrong information

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    It matters not to the Code but I'm curious...why is Mississippi Sate playing two different opponents on the same day?

    Oh, by the way, you have 18 Games in the Master and only 14 in the Weekly Picks. Please post files that represent the same structure as you're actual Files or any Code we write may well fail. Again, this may not matter to the Code...it could matter to you.

    You do the front end work then we'll try to make it work for you...please clean up you're sample Files then we'll work on it...Garbage in...Garbage out...
    Last edited by jaslake; 08-24-2013 at 07:44 PM.

  7. #7
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Ok...I do apologize apparently when I was trying to find out why you had a problem with the games not matching up I didn't count the columns right and added 4 columns that didn't need to be (my original had the right number, just the games didn't match). I have gone back and made the pick sheet and master file match for this year so now no teams play twice (Also I deleted my post earlier to maybe prevent getting anyone else confused by my mistake).

    Attached are two cleaned up versions. I hope this helps make better sense. thanks again.
    Attached Files Attached Files

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    What will be your Workbook Names?

  9. #9
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    They can be the names of my files I attached above or can simply be one called picks and the other master.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    I have the Code written to update Master from Weekly Picks. What I still need from you is to explain how each individual's Weekly Picks get inputed into the Weekly Picks Workbook...what's the Source of that information?

    Here's the Code as it currently stands.
    Please Login or Register  to view this content.
    These two lines of Code will need to be changed to suit your environment.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jaslake; 08-25-2013 at 03:35 PM.

  11. #11
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    First thank you for trying to help me I really appreciate it.

    Ok first I'll answer your question. 30 our so people will be emailed the weekly picks file. They will then email them back to me with their selections made. Previously I'd open each persons file and copy and paste their picks into the master.

    So I tried the code and it copied and pasted the weekly picks into the master but instead of just for one person it did this for all names. I don't know much about VBA but looking at the code you're looking at column L on the weekly picks and I'm not sure why. It appears you have the games and scores pulled correctly from the weekly but it should be looking at cell Z2 to get the name. Once it gets the name it should then find that person's name and what row in the master and paste their picks on that row in the master.

    Hope this helps, thanks again. -Chad

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    This is the piece I'm missing
    I'd open each persons file
    What I want to do is get each persons picks into the Weekly Picks File...the Code will then transfer each persons picks into the Master.

    Depending on the Structure of each persons Pick File, we may be able to bypass the Weekly Picks File altogether. At the moment the Code has no way to discern the individual persons Picks. Need to know where to get them.

    If you please, show me what an individual Pick File looks like.

  13. #13
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    The Weekly Picks file is each persons pick file. All the individuals see in the picks file is columns A-J. In cell C5 the individual will pick their name (currently just Name1, Name2, etc.) and then make their picks. In preparation to make it easy to copy and paste into the master I made columns AA-AN equal what they picked to be easier to copy and paste.

    Each week I will go in and change the games in the weekly pick file and then send it out again so the format will not change to the individual.

    If this still doesn't make sense let me know.

  14. #14
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Ok I've changed a few things and the code now does what I want it to. While I'm sure there are things in the code not right (as it still has a reference to column L in the Sub Fill Master it works. If you can tell me what I can delete that would be great if not Thank you so much for your help. (Changes I made are blue)

    Also, anyway I can make the target worksheet name equal a cell on the source file? Say I put Week 1 in Z1 on the weekly picks it will import into Sheet Week 1 in the master. If it Z1=Week 2 it would attempt to import to sheet Week 2 (which doesn't exist in my example file but will as the season goes on). If not I've tried and figured out if I just keep the current weeks sheet listed first in the master file it imports in the correct sheet. Thanks again.

    Please Login or Register  to view this content.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    Let me understand your process...

    Each week you Email the Weekly Picks File to each Name. This File is of the same structure as the "weekly picks Rev2.xlsx" I've been working with; only difference is Columns K through AP are hidden.

    The Name selects his/her Picks and Emails the File back to you. You download and save each of the attached Files. Where do you save the Files as they're returned and how do you name them? What I wish to do is grab each of these individual Files, loop through them and process their Picks to the Master File. The Code will find and open each of the Files, one by one, and post to the Master. No selecting required.

    Regarding this
    anyway I can make the target worksheet name equal a cell on the source file
    Yes, this is possible. I'll think about it and make a recommendation. Please get back to me.

  16. #16
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Yes that is how the process works. I save the files in different folders for each week for example "H:\Desktop\CFB Pickem\Wk 1 Picks\" then next week picks go into "H:\Desktop\CFB Pickem\Wk 2 Picks\". As far as naming them (last year I didn't because i just open from their email and copied and paste) I was planning on just adding maybe their last name to the end of the file name so filename is sent out as "Games - WEEK 1.xlsx" so I might save them this year "Games - WEEK 1 - Johnson.xlsx". So yeah if there is a way to just tell it go look in Wk 1 Picks and run the process for all the files in that folder that would be great. Only that week's picks are kept in that folder so all files in their should go through the process. The master file and other files are kept in the folder one up "CFB Pickem".

    Thanks again for your help.

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    Is it SOLVED? Shall I stop working on it?

  18. #18
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Look this is the first time I've posted a question. I've always searched this forum and found answers I needed couldn't to this issue. I don't know the protocol, I felt the bulk of the issue was solved so I marked it as so. I think now we are just fine tuning it. I would like you to continue to work on what you were talking about where I wouldn't select indivual files it would maybe read all files in a folder. If I need to mark as unsolved I will.

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    This is your call
    If I need to mark as unsolved I will
    Most members of the Forum, including me, will not look at a SOLVED Thread except for insight into solutions they're researching.

    If you wish it fine tuned to work as you'd like...use your judgment...I'll continue to pursue it...if not...glad I could help. Let me know.

  20. #20
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    I've marked it as unsolved. Please continue to help, would like to make this the best it can be and you've done a tremendous job thus far.

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    The following Code is in the attached Code Book v2.xlsm along with a UserForm. The UserForm will ask you to Select a Week to Process. I'm attaching six files (five attached to this Post...the sixth will be attached to a follow-up post)

    They should be placed like this Directory Tree

    Folder H:\Desktop\CFB Pickem\ <------ Call this whatever you like...put it wherever you like
    Code Book v2.xlsm
    Target Files\
    picks master.xlsx
    Wk 1 Picks\
    Games - Week1 - Harry Cary.xlsx
    Games - Week1 - Joe Johnson.xlsx
    Games - Week1 - Mary Mary.xlsx
    Games - Week1 - Pete Smith.xlsx
    Run the Code from the Button in Code Book v2.xlsm. Let me know of issues.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad...attached is the sixth File
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Magnificent! Great job! There was one small issue at first but after looking at your code I was able to find the problem. In the picks master file the sheet names were Week 1, Week 2 but picks were stored in folder Wk 1 Picks. So at first the picks master file would open and go to correct sheet but wouldn't do anything. Then I saw this code...
    Please Login or Register  to view this content.
    And it hit me the two being different might be the problem so I changed the picks masters sheet names to be Wk 1, Wk 2. It worked! So excellent job!!!

    Now if you're tired of dealing with it I'll understand and you can be done BUT now that I don't click on the files individually my concern is say there are 30 people playing so 30 names listed in picks master file. Lets say there are 28 people (maybe 2 people were on vacation) who submitted picks and their pick files are in the Wk 1 folder. Of the 28 submitted picks 2 of the people forget to select their name in cell C5 (We've put some conditional format stuff and a box about is the pick fully completed Yes or No to limit this because this was a problem last year). So is there a way to get like an error report for it to pop up and say hey there are 28 files in the folder but only 26 were imported. Be even better if it could list the two file names not imported since we will be tacking on the last name to the files.

    If it is not something simple or you don't want to fool with it, it is not a problem. We can just have who ever saves the files from the email to the folder open up that person's file and make sure it has their name prior to saving it to alleviate that problem.

  24. #24
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    Replace the Sub Open_Weekly_File() Code with this Code
    Please Login or Register  to view this content.
    If the Name in Cell C5 does not equal the Workbook Name a Message is displayed and that File is not processed.

  25. #25
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Works like a charm. Last question I promise...is there any way to pull the data from the weekly files without actually having excel open them? Just trying to speed up the code because when there are 30+ files, you can see it open for a second then close then it does the next one workbook and it is taking some time. It doesn't really impact this instance becasue in theory we should only one the code one maybe twice for a given week. I'm really just curious if its possible. Thanks so much for all your help, you've really done an excellent job and I greatly appreciate it!

  26. #26
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    I've heard that this can be done
    ...is there any way to pull the data from the weekly files without actually having excel open them
    but I have no personal experience with it.

  27. #27
    Registered User
    Join Date
    07-18-2011
    Location
    Georgia
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: VBA code to import pick'em picks into master sheet

    Ok no problem. Thanks for all of your help! Problem Solved!

  28. #28
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    You're welcome...glad I could help.

+ 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] Formula in one cell that picks up another based on dates provided in the same sheet
    By s.tara91 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-16-2013, 12:58 AM
  2. vba code for master sheet
    By kandre in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-21-2013, 10:17 AM
  3. VBA Sheet array code not working with drop down lists in master sheet
    By chiplaidlaw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2012, 11:01 AM
  4. Replies: 2
    Last Post: 07-17-2008, 08:37 AM
  5. Validation Pick Lists: Picks containing spaces
    By ComcoDG in forum Excel General
    Replies: 11
    Last Post: 07-15-2008, 04:42 PM

Tags for this Thread

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