Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA: nascondere alcuni fogli

267 views
Skip to first unread message

draleo

unread,
Jan 10, 2010, 7:01:01 AM1/10/10
to
Ho una quindicina di fogli chiamati in vari modi
(Worksheets (“caio”),Worksheets(“sempronio”) ecc
Come fare per nascondere i fogli per es dal num 6 al num 10 ?
Grazie
draleo

plinius

unread,
Jan 10, 2010, 7:28:43 AM1/10/10
to

"draleo" <dra...@discussioni.com> ha scritto nel messaggio
news:6D04684D-0D5E-473C...@microsoft.com...


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.


Mauro Gamberini

unread,
Jan 10, 2010, 9:09:10 AM1/10/10
to
> Ho una quindicina di fogli chiamati in vari modi
> (Worksheets (“caio”),Worksheets(“sempronio”) ecc
> Come fare per nascondere i fogli per es dal num 6 al num 10 ?
>

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/

draleo

unread,
Jan 11, 2010, 2:41:01 PM1/11/10
to
Buone tutte le soluzioni e memorizzate nel mio archivio dei vari argomenti in
VBA
Utilizzerò l'una o l'altra a seconda dei casi
Ringrazio ancora tutti voi
draleo


"Mauro Gamberini" ha scritto:

> .
>

Mauro Gamberini

unread,
Jan 12, 2010, 2:42:22 AM1/12/10
to
> Buone tutte le soluzioni e memorizzate nel mio archivio dei vari argomenti
> in
> VBA
> Utilizzer� l'una o l'altra a seconda dei casi
> Ringrazio ancora tutti voi
>

Grazie a te per il riscontro.

0 new messages