title: Data Validation VBA works when running Excel 2016 on Win7 but does not on Windows 10
body: <p>I'm running a macro that pulls data from a data base and then populates a simple menu using this data.  This function works perfectly when running Excel 2016 on Win7 but when users on Win10 run the macro (also using Excel 2016) an error is thrown on Selection.Validation .add : "1004 object-defined or application-defined error".  Any thoughts about what would cause this error in Win10 vs. Win7 and how I can correct it to work with both operating systems?</p>
  
  <p>I'd prefer not to make a separate tab to hold the validation data, if possible.</p>
  
  <pre><code>Function populateMenu()
  
  
      Dim datafield As ADODB.Field
      Dim datapull As Object
      Dim conn As Object
      Dim sqlQuery As String
      Dim lobNames(200) As Variant
      Dim elementCounter As Integer
  
      Set conn = New ADODB.Connection
      Set datapull = New ADODB.Recordset
      conn.ConnectionString = CONNECTSTRING
      conn.Open
  
  
      sqlQuery = getLOBNames
      datapull.Open sqlQuery, conn
  
       elementCounter = 0
       Do While Not datapull.EOF
          For Each datafield In datapull.Fields
             lobNames(elementCounter) = datafield.Value
             elementCounter = elementCounter + 1
          Next datafield
          datapull.MoveNext
      Loop
  
      datapull.Close
      conn.Close
      Set datapull = Nothing
      Set Connection = Nothing
  
      'LOB Pull Down
      Worksheets("Data").Select
      Range("B3").Select
      With Selection.Validation
          .Delete
          .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(lobNames, ",")
          .IgnoreBlank = True
          .InCellDropdown = True
          .InputTitle = "SELECT LOB"
          .ErrorTitle = ""
          .InputMessage = ""
          .ErrorMessage = ""
          .ShowInput = True
          .ShowError = True
      End With
  
  End Function
  </code></pre>