+ Reply to Thread
Results 1 to 9 of 9

Auto-Populate Cells Based on Drop Down Selection - VBA Excel

  1. #1
    Registered User
    Join Date
    02-07-2017
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Hello,
    Please see the attached two documents, one is a template and the other is a master. They are both simply an example with generic data and headers. I am trying to make a document ("Template") which contains a drop-down in a column, Header 6, in this example. When a product is selected from that drop-down, I would like all of the information in the Template document to be auto-populated into the correct columns with the data found in the Master document.

    The Master document has various tabs for each process as you can see. In the real document, I made this example for privacy purposes, the headers are not named numerically as so. Also, the document is very fluid, so columns will be added and deleted a lot. Therefore, the auto-population has to be able to find the correctly named header and insert the data based on the selected product from the drop-down.

    Please see the attached Master and Template examples for more clarification.

    What do you guys think is the best way to tackle this?

    Currently, I have started by using a change event sub. I have started using a find function to locate the column in both the Template and Master document based on the header names, that way if the columns are moved around it will still find the correct column. There are over 100+ columns in the real document, so there are a lot of arguments in the function. Once I have the correct locations, I was thinking of putting all of the master information and locations into an array, and all of the template locations into another array, then using both arrays to place the information in the template.

    Any better ways? The way I'm doing it seems very long and tedious.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    So what you want is to pick a process page, and then copy the information to the template page. Is this correct?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    02-07-2017
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Quote Originally Posted by dflak View Post
    So what you want is to pick a process page, and then copy the information to the template page. Is this correct?
    I want to select any Product from the dropdown in column "Header 6" on the Template document, which will then copy the corresponding Product data from each Process tab in the Master document to the correct cell in Template document.

  4. #4
    Registered User
    Join Date
    02-07-2017
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Quote Originally Posted by dflak View Post
    So what you want is to pick a process page, and then copy the information to the template page. Is this correct?
    I want to select any Product from the dropdown in column "Header 6" on the Template document, which will then copy the corresponding Product data from each Process tab in the Master document to the correct cell in Template document.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    OK, that's 90 degrees off what I thought it was. I'll take a look at it

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    I changed the name of the files for testing purposes. You can change them back. I indicated in the code where to do this. Only the template has code. The Master workbook does not.

    I put tables in the master workbook, but it turns out I could not use them, so you can use the original master workbook as is.

    I did make a table out of the template because templates copy down formulas automatically.

    Go to Column F and click in the cell where you want to enter data. This should be on the row immediately below the existing table. The code will create a new row for the data that says, "Select Product." You can then use the dropdown box to select the product and the code will look it up.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    02-07-2017
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Quote Originally Posted by dflak View Post
    I changed the name of the files for testing purposes. You can change them back. I indicated in the code where to do this. Only the template has code. The Master workbook does not.

    I put tables in the master workbook, but it turns out I could not use them, so you can use the original master workbook as is.

    I did make a table out of the template because templates copy down formulas automatically.

    Go to Column F and click in the cell where you want to enter data. This should be on the row immediately below the existing table. The code will create a new row for the data that says, "Select Product." You can then use the dropdown box to select the product and the code will look it up.
    Very clean way of doing it. I am going to try and add this to my real document, and make the necessary changes to make it work. Thank you very much! I will let you know if I can get it to work on my real document.

  8. #8
    Registered User
    Join Date
    02-07-2017
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Quote Originally Posted by dflak View Post
    I changed the name of the files for testing purposes. You can change them back. I indicated in the code where to do this. Only the template has code. The Master workbook does not.

    I put tables in the master workbook, but it turns out I could not use them, so you can use the original master workbook as is.

    I did make a table out of the template because templates copy down formulas automatically.

    Go to Column F and click in the cell where you want to enter data. This should be on the row immediately below the existing table. The code will create a new row for the data that says, "Select Product." You can then use the dropdown box to select the product and the code will look it up.
    So I'm running into an issue. When I try to open the master file, it is resetting the change event macro and going back to the start of the script. I have disabled the events right before opening the workbook, but it still does the same thing. It makes it through the top part of the code, so the file does exist. Then when it goes to open the workbook, the macro starts over again as if enableevents is not disabled. I have checked the Locals window and see that enableevents is indeed false when running, so I'm not sure what else I can do...

    Please Login or Register  to view this content.

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Auto-Populate Cells Based on Drop Down Selection - VBA Excel

    Looking at the code, I can't see why anything would kick off an event on file open of the master file. The only thing I can think of is if there is a formula on sheet Temp that doesn't change value until the form is open- Maybe an INDIRECT or something like that. This might kick off the selection change event which then sets the events back to true.

    I cannot duplicate the issue. I suggest putting in a msgbox or two to track progress through the logic.

+ 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] Auto-populate cells based on drop down list selection
    By sh1483 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-01-2016, 11:59 PM
  2. [SOLVED] Auto-populate fields based on drop down selection
    By kwo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-23-2015, 07:15 AM
  3. Auto Populate cells based on Drop-down selection
    By stepzuko in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-11-2014, 03:02 PM
  4. Replies: 6
    Last Post: 01-02-2014, 10:38 AM
  5. drop down selection to auto populate multiple cells
    By chika90 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2013, 10:08 AM
  6. Auto-populate field based on drop down box selection
    By nicfarrell in forum Excel General
    Replies: 7
    Last Post: 01-21-2013, 12:47 AM
  7. [SOLVED] Auto populate several cells based on a selection from drop down li
    By Sheldon in forum Excel General
    Replies: 3
    Last Post: 01-13-2006, 04:30 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