Public Function GenerateDV(Range1 As String, Range2 As String)
[FONT=Courier] [COLOR=#00007F]Dim[/COLOR] Rng1 [COLOR=#00007F]As[/COLOR] Range, Rng2 [COLOR=#00007F]As[/COLOR] Range, c [COLOR=#00007F]As[/COLOR] Range
[COLOR=#00007F]Dim[/COLOR] rowdiff [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]Long[/COLOR], coldiff [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]Long[/COLOR]
[COLOR=#00007F]Dim[/COLOR] DVvals [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]String[/COLOR]
[COLOR=#00007F]Set[/COLOR] Rng1 = Range(Range1)
[COLOR=#00007F]Set[/COLOR] Rng2 = Range(Range2)
[COLOR=#00007F]If[/COLOR] Rng1.Rows.Count = Rng2.Rows.Count And _
Rng1.Columns.Count = Rng2.Columns.Count [COLOR=#00007F]Then[/COLOR]
rowdiff = Rng1.Row - Rng2.Row
coldiff = Rng1.Column - Rng2.Column
Rng2.Validation.Delete
[COLOR=#00007F]For[/COLOR] [COLOR=#00007F]Each[/COLOR] c [COLOR=#00007F]In[/COLOR] Rng2.Cells
DVvals = c.Offset(rowdiff, coldiff).Value
DVvals = Replace(DVvals, " vs ", ",", 1, -1, vbTextCompare)
[COLOR=#00007F]If[/COLOR] Len(DVvals) > 0 and c.value = 0 [COLOR=#00007F]Then[/COLOR]
[COLOR=#00007F]With[/COLOR] c.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=DVvals
.IgnoreBlank = [COLOR=#00007F]True[/COLOR]
.InCellDropdown = [COLOR=#00007F]True[/COLOR]
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = [COLOR=#00007F]True[/COLOR]
.ShowError = [COLOR=#00007F]True[/COLOR]
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]With[/COLOR]
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]If[/COLOR]
[COLOR=#00007F]Next[/COLOR] c
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]If[/COLOR]
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]Sub[/COLOR][/FONT]