(VBA) Liste déroulante (validation)

Hello le forum,

Dsl pour mon incompétence ... je galère toujours autant avec ces listes déroulantes ... en VBA.

voici mon code qui génère une erreur 1004 sur formula1... Pourriez-vous me corriger svp :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo 0
If Not Application.Intersect(Target, Range("R2:R9000")) Is Nothing Then
'Application.EnableEvents = False
Dim Tout_Manager As Range, Ligne_Liste As Integer, Liste As Worksheet
Ligne_Liste = Sheets("Liste_BELLINI").Range("X1000").End(xlUp).Row
With Sheets("Liste_BELLINI")
    Set Tout_Manager = .Range(.Cells(2, 24), .Cells(Ligne_Liste, 24))
End With

   With ActiveCell.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Liste_BELLINI!" & Tout_Manager.Address
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
Application.EnableEvents = True
End If

Merci à vous

R@g

Bonjour,

J'ai testé ton code sous Excel 2007 et Excel 365, il fonctionne bien.

Si tu as une erreur, je ne sais pas d'où elle provient.

Aurais-tu un bout de fichier reproduisant l'erreur à soumettre ?

ric

Hello ric,

Merci pour ta réponse.

Tu as raison mon code fonctionne bien, la raison c'est que je suis en style L1C1 et comme address renvoie un style A1 ça ne fonctionne pas ...

Il n 'y a pas une méthode pour corriger ce souci ? Mettre la commande vba pour passer en mode A1 mais bon c'est chiant faut y penser ...

R@g

Bonjour,

Si ton classeur est en mode L1C1 ...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo 0

If Not Application.Intersect(Target, Range(Cells(2, 18), Cells(9000, 18))) Is Nothing Then
'Application.EnableEvents = False
   Dim Tout_Manager As Range, Ligne_Liste As Integer, Liste As Worksheet

   Ligne_Liste = Sheets("Liste_BELLINI").Cells(1000, 24).End(xlUp).Row

   With Sheets("Liste_BELLINI")
      Set Tout_Manager = .Range(.Cells(2, 24), .Cells(Ligne_Liste, 24))
   End With

   With ActiveCell.Validation
      .Delete
      .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
           xlBetween, Formula1:="=Liste_BELLINI!" & Tout_Manager.Address
      .IgnoreBlank = True
      .InCellDropdown = True
      .InputTitle = ""
      .ErrorTitle = ""
      .InputMessage = ""
      .ErrorMessage = ""
      .ShowInput = True
      .ShowError = True
   End With
   Application.EnableEvents = True

End If

End Sub

ric

Rechercher des sujets similaires à "vba liste deroulante validation"