Sub CmdImpHeb_Click()
Dim WS As Worksheet
Dim WeekRange As Range
Dim Cell As Range, Cel As Range, CelStart As Range, CelEnd As Range
Dim WeekPrintArea As Range
Dim WeekSearch As String
Dim CellCurrentRegion As Range
Dim Col As Byte, Lig As Integer
WeekSearch = Me.Semaine
If WeekSearch = '' Then Exit Sub
For Each WS In ThisWorkbook.Worksheets
If Not WS.Name = 'HC' And Not WS.Name = 'MAJ' Then
MsgBox 'Traitement : ' & WS.Name '**** TEST A SUPPRIMER ENSUITE !
Set WeekRange = WS.Range('A1:A100')
For Each Cell In WeekRange
If Cell.Text = WeekSearch Then
Unload Me
Set CelStart = Cell.Offset(-2, 0)
Set CellCurrentRegion = Cell.CurrentRegion
Lig = CellCurrentRegion.Rows.Count + Cell.Row - 1
Col = CellCurrentRegion.Columns.Count + Cell.Column - 1
Col = IIf(Col < 14, 14, Col)
Set CelEnd = WS.Cells(Lig, Col)
If Not CelStart Is Nothing And Not CelEnd Is Nothing Then
Set WeekPrintArea = Range(CelStart, CelEnd)
Else
Set WeekPrintArea = Range(CelStart, Cell.Offset(18, 22))
End If
With WS
.Activate
.PageSetup.PrintArea = WeekPrintArea.Address
.PrintPreview '**** Pour tester sans gaspillage
'.PrintOut 'Pour Imprimer sur activePrinter
End With
End If
Next Cell
End If
Next WS
End Sub