venerdì 1 maggio 2009

VBA Office : Menu a discesa con i nomi dei fogli excel


Autore : Mike Holness, mpep
Commento : Permette di creare un menu a discesa, con tutti i nomi dei fogli.

Sub ListOfSheets()
Mike Holness, mpep
' Generate string containing all the names
Dim NameList As String
Dim xSheet As Object
   For Each xSheet In Sheets
             NameList = NameList & xSheet.Name & ","
    Next xSheet
  ' Remove the trailing comma
     NameList = Left(NameList, Len(NameList) - 1) 
     With Selection.Validation
         .Delete
         .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
         Operator:=xlBetween, Formula1:=NameList
         .IgnoreBlank = True
         .InCellDropdown = True
         .InputTitle = ""
         .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
End With
End Sub

Nessun commento:

Posta un commento