Change several Dropdown box values at once

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Change several Dropdown box values at once

Post by bradjedis »

Hey everone,

I have an interesting question... I have 20 dropdown boxes that each contain 'Yes' & 'No' we are looking to have a button assigned to a macro to toggle all of them at once. Reasoning is if it is a Yes, there is other code that acts upon the Yes, and triggers an e-mail.

If they are set to Yes, we would want to toggle all to No. and If they all contain No, we would want to toggle to Yes.

Any Ideas?


Thanks,
Brad

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change several Dropdown box values at once

Post by HansV »

What kind of dropdown boxes are these?
  1. On a worksheet, from the Forms toolbar.
  2. On a worksheet, from the Control Toolbox.
  3. On a userform (created in the Visual Basic Editor)
Apart from that:
  • Are there other dropdown boxes than the 20 you mention?
  • Have you given them consistent names, for example ComboBox1, ComboBox2, ..., ComboBox20 ?
Best wishes,
Hans

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Re: Change several Dropdown box values at once

Post by bradjedis »

Hans,
There are 2 columns. They are pulling the Yes/No from a different set of cells on the same tab. Looks like they are suing data validation to populate the list.

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change several Dropdown box values at once

Post by HansV »

OK, so you need to set the values of a range of cells to 'Yes' or to 'No'. What is the range?
Best wishes,
Hans

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Re: Change several Dropdown box values at once

Post by bradjedis »

Range of cells is E2:24

Brad

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change several Dropdown box values at once

Post by HansV »

You could use code like this in a macro:

Code: Select all

If Range("E2") = "No" Then
  Range("E2:E24") = "Yes"
Else
  Range("E2:E24") = "No"
End If
Best wishes,
Hans

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Re: Change several Dropdown box values at once

Post by bradjedis »

Coolness.

Thanks and have a great weekend!

Brad

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change several Dropdown box values at once

Post by HansV »

You too!
Best wishes,
Hans