Nel post precedente intendevo dire una cosa del genere
download file esempioComposto da:
1) un foglio aggiunto alla cartella avente nome "Elenco"
2) una macro nel modulo che si avvia con un pulsante
3) un codice nel Vba del foglio "Elenco" che permette di visualizzare il foglio selezionato (colonna A del foglio Elenco) nascondendo tutti gli altri
La macro che crea l'elenco dei fogli e situata nel modulo è questa:
- Codice: Seleziona tutto
Sub CreaElenco()
UR = Worksheets("Elenco").Cells(Rows.Count, 1).End(xlUp).Row
If UR < 2 Then UR = 2
Worksheets("Elenco").Range("A2:A" & UR).ClearContents
For CF = 1 To Worksheets.Count
If Worksheets(CF).Name <> "Elenco" Then
Worksheets("Elenco").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Worksheets(CF).Name
End If
Next CF
End Sub
La macro trascritta nel Vba del foglio "Elenco", questa:
- Codice: Seleziona tutto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UR = Worksheets("Elenco").Cells(Rows.Count, 1).End(xlUp).Row
If UR < 2 Then Exit Sub
If (Selection.Rows.Count + Selection.Columns.Count) > 2 Then Exit Sub
If Intersect(Target, Range("A2:A" & UR)) Is Nothing And Target = "" Then Exit Sub
For CF = 1 To UR
If Worksheets(CF).Name <> "Elenco" And Worksheets(CF).Name <> Target Then
Worksheets(CF).Visible = False
Else
Worksheets(CF).Visible = True
NomeF = Worksheets(CF).Name
End If
Next CF
Worksheets(NomeF).Select
End Sub
Fai sapere se tutto ok
ciao