1) macro che genera l'elenco, da inserire in un modulo:
Sub aggiorna_elenco()
Dim ListaNomi2 As String
Dim Foglio As Object
Range("a1").Select
For Each Foglio In Sheets
If Foglio.Name <> "diverso" Then
ListaNomi2 = ListaNomi2 & Foglio.Cells(1, 5) & ","
End If
Next Foglio
ListaNomi2 = Left(ListaNomi2, Len(ListaNomi2) - 1)
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=ListaNomi2
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
2) macro che attiva l'aggiornamento all'apertura della cartella, da inserire nel ThisWorkbook:
Private Sub Workbook_Open()
Sheets("FoglioA").Range("A1").Select
aggiorna_elenco
End Sub
3) macro che attiva l'aggiornamento quando si seleziona la cella a1 del foglioa, da inserire nel foglioa:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
aggiorna_elenco
End If
End Sub
|