Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Nommer une liste créée par VBA

2 réponses
Avatar
Patrick BASTARD
Bonjour à tous.

Ce code crée une liste de validation à partir des zones nommées du classeur.
Comment nommer cette liste pour l'utiliser, à la place de
".Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="=$N$1:$N$16"" ?

***********************************************
'copie et colle la liste des noms à partir de N1 et Définit la liste de
validation en K1
Sheets("Impression").Activate
Range("N1").Select
Selection.ListNames
Columns("O:O").Select
Selection.Delete Shift:=xlToLeft
Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween,
Formula1:="=$N$1:$N$16"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "SELECTION DU SOUS-TRAITANT"
.ErrorTitle = ""
.InputMessage = "Clic sur le nom choisi"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

'Suppression des noms inutiles
Range("N1").Select
Cells.Find(What:="Base", After:=ActiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:=ActiveCell).Activate
Selection.Delete Shift:=xlUp
Range("N1").Select
Cells.Find(What:="Zone_d_impression", After:=ActiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:=ActiveCell).Activate
Selection.Delete Shift:=xlUp
***********************************************
D'avance, merci.
--
Bien amicordialement,
P. Bastard

Avant d'imprimer ce mail, ayez une pensée pour les arbres.

2 réponses

Avatar
Ellimac
Bonjour Patrick,

Sub Macro1()
Range("N1").Select
Selection.ListNames
ActiveWorkbook.Names.Add Name:="MyListe", RefersToR1C1:= _
Range(Range("n1"), Range("n1").End(xlDown))
With Range("k1").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=MyListe"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub

Camille


Bonjour à tous.

Ce code crée une liste de validation à partir des zones nommées du classeur.
Comment nommer cette liste pour l'utiliser, à la place de
".Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="=$N$1:$N$16"" ?

***********************************************
'copie et colle la liste des noms à partir de N1 et Définit la liste de
validation en K1
Sheets("Impression").Activate
Range("N1").Select
Selection.ListNames
Columns("O:O").Select
Selection.Delete Shift:=xlToLeft
Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween,
Formula1:="=$N$1:$N$16"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "SELECTION DU SOUS-TRAITANT"
.ErrorTitle = ""
.InputMessage = "Clic sur le nom choisi"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

'Suppression des noms inutiles
Range("N1").Select
Cells.Find(What:="Base", After:¬tiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:¬tiveCell).Activate
Selection.Delete Shift:=xlUp
Range("N1").Select
Cells.Find(What:="Zone_d_impression", After:¬tiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:¬tiveCell).Activate
Selection.Delete Shift:=xlUp
***********************************************
D'avance, merci.
--
Bien amicordialement,
P. Bastard

Avant d'imprimer ce mail, ayez une pensée pour les arbres.





Avatar
Patrick BASTARD
Bonsoir, Camille.

ActiveWorkbook.Names.Add Name:="MyListe", RefersToR1C1:= Range(Range("n1"),
Range("n1").End(xlDown))
doit convenir.
Je m'étais lancé dans Edition, atteindre, cellules, zone en cours avec
l'enregistreur, mais ta solution est bien plus élégante.
Je te remercie,

--
Bien amicordialement,
P. Bastard

Avant d'imprimer ce mail, ayez une pensée pour les arbres.



Bonjour Patrick,

Sub Macro1()
Range("N1").Select
Selection.ListNames
ActiveWorkbook.Names.Add Name:="MyListe", RefersToR1C1:= _
Range(Range("n1"), Range("n1").End(xlDown))
With Range("k1").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _ xlBetween, Formula1:="=MyListe"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub

Camille


Bonjour à tous.

Ce code crée une liste de validation à partir des zones nommées du
classeur.
Comment nommer cette liste pour l'utiliser, à la place de
".Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="=$N$1:$N$16"" ?

***********************************************
'copie et colle la liste des noms à partir de N1 et Définit la liste
de
validation en K1
Sheets("Impression").Activate
Range("N1").Select
Selection.ListNames
Columns("O:O").Select
Selection.Delete Shift:=xlToLeft
Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _

xlBetween, Formula1:="=$N$1:$N$16"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "SELECTION DU SOUS-TRAITANT"
.ErrorTitle = ""
.InputMessage = "Clic sur le nom choisi"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

'Suppression des noms inutiles
Range("N1").Select
Cells.Find(What:="Base", After:¬tiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:¬tiveCell).Activate
Selection.Delete Shift:=xlUp
Range("N1").Select
Cells.Find(What:="Zone_d_impression", After:¬tiveCell,
SearchOrder:=xlByColumns).Activate
Cells.FindNext(After:¬tiveCell).Activate
Selection.Delete Shift:=xlUp
***********************************************
D'avance, merci.
--
Bien amicordialement,
P. Bastard

Avant d'imprimer ce mail, ayez une pensée pour les arbres.