Bonjour le forum, bonjour les gens,
Après avoir utiliser la petite moulinette précédente, il faut réinitilaliser la feuille.
Voici donc la procédure.
Sub Affiche_Col()
'
' Macro enregistrée le 01/08/2005 par Humansoft ©2005
'
'
Dim zv_Col As Variant
Dim zi_Nb As Integer
Sheets('Récapitulatif').Unprotect
For zi_Nb = 68 To 106
If zi_Nb >= 91 Then
'zi_Nb = zi_Nb - 26
zv_Col = 'A' & Chr(zi_Nb - 26)
If Range('' & zv_Col & '39').Value = 0 Then
Columns('' & zv_Col & ':' & zv_Col & '').Select
Selection.EntireColumn.Hidden = False
End If
Else
zv_Col = Chr(zi_Nb)
If Range('' & zv_Col & '39').Value = 0 Then
Columns('' & zv_Col & ':' & zv_Col & '').Select
Selection.EntireColumn.Hidden = False
End If
End If
Next zi_Nb
Range('A1').Select
Sheets('Récapitulatif').Protect
End Sub
Si tu souhaite imprimer ta sélection, voici une procédure toute prète.
Bien sûr, elle est liée à mon classeur mais les modifications à faire pour ton classeur devraient être minimes.
Sub Print_Sheets(ByVal ps_Shet As String)
'
' Macro enregistrée le 01/08/2005 par Humansoft ©2005
' Cette macro fonctionne depuis l'appel depuis un menu
' La variable ps_shet correspond au nom de la feuille à imprimer
' De Janvier à Décembre ou Récapitulatif
'
Dim zv_Dat As Variant
Dim zs_Prn, zs_Msg As String
zs_Msg = ' IMPRESSION DES DOCUMENTS' _
& vbCrLf & vbCrLf & 'Seules les colonnes contenant des chiffres ' _
& vbCrLf & ' apparaissent sur le récapitulatif.' _
& vbCrLf & vbCrLf & 'Pour chaque mois, toutes les colonnes,' _
& vbCrLf & 'même vides, seront imprimées.'
zs_Prn = ''
Select Case ps_Shet
Case '01': zs_Prn = 'Janvier '
Case '02': zs_Prn = 'Février '
Case '03': zs_Prn = 'Mars '
Case '04': zs_Prn = 'Avril '
Case '05': zs_Prn = 'Mai '
Case '06': zs_Prn = 'Juin '
Case '07': zs_Prn = 'Juillet '
Case '08': zs_Prn = 'Août '
Case '09': zs_Prn = 'Septembre '
Case '10': zs_Prn = 'Octobre '
Case '12': zs_Prn = 'Novembre '
Case '12': zs_Prn = 'Décembre '
End Select
If zs_Prn = '' Then
zs_Prn = ps_Shet
End If
Sheets(ps_Shet).Select
If ps_Shet = 'Récapitulatif' Then
Efface_Col ' Lapremière moulinette
Range('A1:AQ1').Select
ActiveWindow.Zoom = True
Range('A1').Select
End If
zv_Dat = 'Année ' & Format(Range('Saisie!C4').Value, 'YYYY')
'Recap et mois
MsgBox zs_Msg, vbInformation, vs_Tit
ActiveSheet.PageSetup.PrintArea = '$A$2:$AQ$42'
With ActiveSheet.PageSetup
.LeftHeader = '&''Verdana,Gras''&7' & zs_Prn & ' ' & zv_Dat
.CenterHeader = ''
.RightHeader = ''
.LeftFooter = '&''Verdana,Normal''&7GestionVB Compta - ©2003-2005 Humansoft'
.CenterFooter = ''
.RightFooter = '&''Verdana,Normal''&7Edition du &D'
.LeftMargin = Application.InchesToPoints(0.393700787401575)
.RightMargin = Application.InchesToPoints(0.393700787401575)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0.78740157480315)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintQuality = 600
.CenterVertically = False
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
End With
If ps_Shet <> 'Récapitulatif' Then
With ActiveSheet.PageSetup
.FitToPagesWide = False '1
End With
Else
With ActiveSheet.PageSetup
.FitToPagesWide = 1
End With
End If
ActiveWindow.SelectedSheets.PrintOut Preview:=True
ActiveSheet.PageSetup.PrintArea = ''
If ps_Shet = 'Récapitulatif' Then
Affiche_Col ' la seconde moulinette
End If
Range('A1').Select
Sheets('Accueil').Select
End Sub
Voilà pour le code
Bonne utilisation
Vincent