Populating Multiple Cells from Single Data Validation (Drop Down) List

Philip Treacy

March 3, 2016

If you want to limit the choices available for the values that can be entered into a cell, you could use a data validation list.

In the example image below, we are creating a roster for the teachers that are on playground duty during the week.

Data Validation List in Table

The data is laid out as a table, and I am using conditional formatting to highlight any duplicates across rows, and down columns. No teacher can be on duty twice in the same day, or be on duty for the same period during the week.

So when I select Claire for A.M. Recess & Lunch on Thursday, my conditional formatting rules warn me. Likewise when I assign Bob to A.M. Recess & Lunch on Friday, and Lunch on Wednesday, the CF rules let me know.

This works nicely but we have to set up data validation for each cell in the table. If we write a little VBA, we can use just one DV list to populate the entire row.

In the image below we can see I am using just one list at the start of each row, and each time I make a selection, the next empty cell in the row is populated.

Not only that, if I make a mistake, I can choose the blank first entry in the list, and this deletes the last value in the row. Or I can press the Delete key to do the same thing.

I can also delete cells in the middle of the row (and they don't have to be adjacent cells), then use the list to fill in the gaps.

This table is using the same conditional formatting rules as the first table.

Data Validation List Using VBA in Table

VBA Code

The VBA uses the Worksheet_Change event so you'll find the code in the Sheet1 module.

Enter your email address below to download the sample workbook.

By submitting your email address you agree that we can email you our Excel newsletter.
AUTHOR Philip Treacy Co-Founder / Owner at My Online Training Hub

Systems Engineer with 30+ years working for companies like Credit Suisse and E.D.S. in roles as varied as Network & Server Support, Team Leader and Consultant Project Manager.

These days Philip does a lot of programming in VBA for Excel, as well as PHP, JavaScript and HTML/CSS for web development.

He's particularly keen on Power Query where he writes a lot of M code.

When not writing blog posts or programming for My Online Training Hub, Philip can be found answering questions on the Microsoft Power BI Community forums where he is a Super User.

4 thoughts on “Populating Multiple Cells from Single Data Validation (Drop Down) List”

  1. Hi Phil
    I’ve had to deal with similar (multiple condition / exclusivity) situations as this before, and usually settle for a custom formula to apply the validation rules, but in doing so give up the drop-down list functionality.

    In your example, the following custom formula in the Settings Source field for cell C7 will apply the rules the school principal specified:
    =AND( COUNTIFS($C7:$G7, C7)<=1, COUNTIFS( C$7:C$9, C7) <=1 )

    I may now look to use some VBA to get the best of both worlds.
    Cheers

    Reply

Leave a Comment

Current ye@r *