Bonjour,
Lors d'un choix dans une combobox d'un certain domaine [ Range("Q4:Q63") ] on souhaite sélectionner une plage plus réduite d'autre données.
La procédure pour la sélection des plages plus réduite fonctionne bien mais pour le choix dans la première combobox, je ne peux le faire que pour une cellule ( dans mon cas "Q4").
Le code parlera plus.
Voici l'appel de la macro lors des changements dans les combobox :
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case Range("Q4").Address ' ou Case Range("Q4").ends(xldown).adress
Application.Run "'" & Excel.ActiveWorkbook.Path & "\MaMacro.xls'!MacrosChange"
End Select
End Sub
Et voilà la macro ( qui rempli son rôle mais que pour un case...) :
Public Sub MacrosChange()
'
' Selection des codes projets en fonction du nom du domaine
' Macro enregistrée le 18/06/2009 par odaxys
'
If Range("Q4").Text = "Domaine1" Then
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=CdPr1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("Q4").Text = "Domaine2" Then
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=CdPr2"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("Q4").Text = "Domaine3" Then
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=CdPr3"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Else
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=CdPr"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
End Sub
J'ai déjà essayé :
Select Case Target.Address
Case Range("Q4").Address ' ou Case Range("Q4").ends(xldown).adress
Mais ça ne rentre pas dans le Case.
Je suis si près du but.
MerciConfiguration: Windows XP
Firefox 3.0.11

