[VBA] En macro en procédure

Bonjour,

J'ai essayé de faire une macro qui met une validation sur une cellule (ou selection). J'aimerai la transformer en procédure. Avec en argument une "Range" (ou cellule)

J'ai essayé mais j'ai mal dû m'y prendre.

Voici le bout de code:
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="AND; OR; LIKE"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With


Merci d'avance et bonne soirée.
Configuration: Windows XP
Firefox 2.0.0.11

1 réponse

  1. Presque réglé, mais la liste déroule marche mal. (cf. screen : http://img140.imageshack.us/img140/5088/screenshotuo9.jpg)

    Sub Macro6(t As String)
        Range(t).Select
        With Selection.Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula1:="1;2;3"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With
    End Sub
    
    0