Data validation automatically set to first item in list

dirtychinchilla

Board Regular
Joined
Jun 21, 2013
Messages
234
Morning sirs,

I've been having a good look around for this, but am struggling to find a solution that works.

I have various data validation lists, and would like them automatically to be set to their first value when they are set up (uses a macro). Does anyone have any idea how this might be done?

Thanks in advance,

dirtychinchilla
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi Andrew,

I must apologise for my lack of response; I was off for a couple of days and have been focused on something else since Monday.

Validation.Formula1 is "=INDIRECT(UnitTypeTran)" which is the translator for one of the data validation boxes.
 
Upvote 0
Basically, I use data validation ranges to select a product. But the products are called things like AM 100, AM 300 etc. and the spaces are deemed necessary. But to make the data validation change according to your selection of AM 100 or whatever, the product you click on is then translated (hence the "Tran") ie Am 100 gives a range of AM_100. This is done in the UnitTypeTran range, which just uses an if statement.
 
Upvote 0
Try:

Code:
Sub Test()
    Dim Cell As Range
    For Each Cell In ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation).Cells
        With Cell
            If .Validation.Type = xlValidateList Then
                If InStr(.Validation.Formula1, "=INDIRECT") > 0 Then
                    .Value = Range(Range(Replace(Replace(.Validation.Formula1, "=INDIRECT(", ""), ")", "")).Value).Cells(1, 1).Value
                Else
                    .Value = Range(Replace(.Validation.Formula1, "=", "")).Cells(1, 1).Value
                End If
            End If
        End With
    Next Cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,794
Members
449,468
Latest member
AGreen17

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