ClearContents in relation to data validation lists

Darren_workforce

Board Regular
Joined
Oct 13, 2022
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a very basic training simulator setup in Excel which is designed to replicate a window of an external application. I have VBA code setup so that when someone is done practicing, they can click on a button and it clears all cells that have user-entered data. Very basic: Range("C7:G8").ClearContents, but my issue is that aside from the user entry fields, I have a number of data validation lists that are setup so the trainee can just click and select from the dropdown menus. It is setup so that the default values are displayed based on the actual production application. For the purposes of the simulator, the "default" values are just setup as the first item within each data validation list.

Can something be setup within VBA similar to ClearContents but instead of it clearing the data validation lists entirely, instead it would revert each of the data validation fields back to whatever their default value was within the lists?

Thank you for any and all assistance!!
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I should add that the data validation lists are located in a hidden worksheet within the same workbook. If that matters. Using the macro recorder, within a test cell, I developed

Excel Formula:
Range("V12").Select
    ActiveCell.FormulaR1C1 = "=Sheet2!R[-2]C[-20]"

I just basically asked VBA to replicate whatever was in the Sheet2!R[-2]C[-20] to display in V12. It appears to have done what I needed and while I think I technically worked it out, if there's a simpler formula to update all 5 data validation fields quickly, I'm open to professional opinion.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top