For i = 6 to 10
Thisworkbook.Worksheets(i).visible = xlVeryHidden
Next
oppure, se vuoi che possano essere rivisualizzati dall'utente,
For i = 6 to 10
Thisworkbook.Worksheets(i).visible = False
Next
Ciao,
E.
Puoi fare questa cosa in più modi,
più o meno *sicuri* a seconda del contesto.
Per posizione:
Public Sub m()
Dim wk As Workbook
Dim sh As Worksheet
Set wk = ThisWorkbook
With wk
For Each sh In Worksheets(Array(1, 3, 7))
sh.Visible = xlSheetVeryHidden
Next
End With
Set wk = Nothing
Set sh = Nothing
End Sub
Ciclare fra fogli diversi in base al nome del foglio:
Public Sub mm()
Dim wk As Workbook
Dim sh As Worksheet
Set wk = ThisWorkbook
With wk
For Each sh In Worksheets(Array("Foglio1", "Foglio4", "Foglio5"))
sh.Visible = xlSheetVeryHidden
Next
End With
Set wk = Nothing
Set sh = Nothing
End Sub
Creare un Array di fogli:
Public Sub mmm()
Dim wk As Workbook
Dim shArray As Sheets
Dim sh As Worksheet
On Error GoTo RigaErrore
With wk
Set shArray = Worksheets(Array("Foglio2", "Foglio6"))
For Each sh In shArray
sh.Visible = xlSheetVeryHidden
Next
End With
RigaChiusura:
Set sh = Nothing
Set wk = Nothing
Set shArray = Nothing
Exit Sub
RigaErrore:
MsgBox Err.Number & vbNewLine & Err.Description
Resume RigaChiusura
End Sub
Per posizione può creare problemi se vengono spostati,
eliminati o aggiunti fogli che modificano l'ordine.
Per nome può creare problemi se vengono modificati i nomi
(lo stesso vale per l'array).
--
---------------------------
Mauro Gamberini
Microsoft MVP - Excel
http://www.riolab.org/
http://www.maurogsc.eu/
http://social.microsoft.com/Forums/it-IT/excelit/threads/
"Mauro Gamberini" ha scritto:
> .
>
Grazie a te per il riscontro.