J'essaie de valider une colonne spécifique qui utilise une validation de liste. Si (colonne "Table (T) / Ligne (L)" = "L") utilisez un tableau spécifique, si (colonne "Table (T) / Ligne (L)" = "t") utilisez un autre tableau. J'utilise ce code ci-dessous mais il ne fonctionne pas. La liste contient des valeurs incorrectes:
Function check_alignment_column()
Dim cell As Range, j As String
msg = ""
Set rngCheck = Range([c3], Cells(Rows.Count, "C").End(xlUp))
Set rngcheck2 = Range([m3], Cells(Rows.Count, "M").End(xlUp))
For Each cell In rngCheck
If cell.value = "L" Then
With rngcheck2.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Lists!E2:E5"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
If cell.value = "T" Then
With rngcheck2.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Lists!F2:F29"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
Next cell
End Function