Sub Action()
Application.ScreenUpdating = False
Dim datejour As String 'nom onglet date de depart'
Dim dateref As String 'nom onglet date ref antérieure'
Dim FileName As Variant 'nom du classeur data
Dim ThePath As String
Dim Classeur1 As String 'nom du classeur Cale Tarifs
Dim cel1 As String 'Segment de départ
Dim cel2 As String 'segment parametre
Dim cel3 As String 'résultat code segment
Dim i As Integer 'compteur de ligne
Dim ii As Integer 'compteur de ligne
Dim iii As Integer 'compteur de ligne
Dim iiii As Integer 'compteur de ligne
Dim Som As Single 'adition segment
Classeur1 = ActiveWorkbook.Name
Sheets("Parametres").Select
'------------------------------------------------------
'saisie des données de date
datejour = InputBox("Saisir date du jour sous forme dd-mm-aaaa !")
dateref = InputBox("Saisir date de ref sous forme dd-mm-aaaa !")
Range("D1") = datejour
Range("D3") = dateref
'------------------------------------------------------
'Annulation des filtres de tris'
Sheets("Point Tarifs").Select
Application.Run "'01-Cale Tarifs 2012.xls'!Effacer_tri_filtre"
Sheets("Hotel 1").Select
Application.Run "'01-Cale Tarifs 2012.xls'!Effacer_tri_filtre"
'------------------------------------------------------
'Ouverture du fichier data'
'Selection du classeur sous format xls'
FileName = Application.GetOpenFilename(fileFilter:="xls Files (*.xls), *.xls")
If FileName = False Then Exit Sub
'ouverture du classeur'
ThePath = FileName
Workbooks.Open FileName
FileName = ActiveWorkbook.Name
'------------------------------------------------------
'Position sur 1er date et nettoyage des codes segment
Sheets(datejour).Select
Range("b2:ab2").ClearContents 'nettoyage code hotel 1
Range("ae2:be2").ClearContents 'nettoyage code hotel 2
Range("bh2:ch2").ClearContents 'nettoyage code hotel 3
Range("ck2:dk2").ClearContents 'nettoyage code hotel 4
'Position sur 2eme date et nettoyage des codes segment
Sheets(dateref).Select
Range("b2:ab2").ClearContents 'nettoyage code hotel 1
Range("ae2:be2").ClearContents 'nettoyage code hotel 2
Range("bh2:ch2").ClearContents 'nettoyage code hotel 3
Range("ck2:dk2").ClearContents 'nettoyage code hotel 4
'------------------------------------------------------
'Attribution des codes segments Hotel 1 1er page
For ii = 0 To 26
Workbooks(FileName).Worksheets(dateref).Activate
cel1 = Cells(3, ii + 2)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 2)
End If
Next i
Workbooks(FileName).Worksheets(dateref).Activate
Cells(2, ii + 2) = cel3
Next ii
'Attribution des codes segments Hotel 2 1er page
For ii = 0 To 26
Workbooks(FileName).Worksheets(dateref).Activate
cel1 = Cells(3, ii + 31)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 3)
End If
Next i
Workbooks(FileName).Worksheets(dateref).Activate
Cells(2, ii + 31) = cel3
Next ii
'Attribution des codes segments Hotel 3 1er page
For ii = 0 To 26
Workbooks(FileName).Worksheets(dateref).Activate
cel1 = Cells(3, ii + 60)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 4)
End If
Next i
Workbooks(FileName).Worksheets(dateref).Activate
Cells(2, ii + 60) = cel3
Next ii
'Attribution des codes segments Hotel 4 1er page
For ii = 0 To 26
Workbooks(FileName).Worksheets(dateref).Activate
cel1 = Cells(3, ii + 89)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 5)
End If
Next i
Workbooks(FileName).Worksheets(dateref).Activate
Cells(2, ii + 89) = cel3
Next ii
'------------------------------------------------------
'Attribution des codes segments Hotel 1 2eme page
For ii = 0 To 26
Workbooks(FileName).Worksheets(datejour).Activate
cel1 = Cells(3, ii + 2)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 2)
End If
Next i
Workbooks(FileName).Worksheets(datejour).Activate
Cells(2, ii + 2) = cel3
Next ii
'Attribution des codes segments Hotel 2 2eme page
For ii = 0 To 26
Workbooks(FileName).Worksheets(datejour).Activate
cel1 = Cells(3, ii + 31)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 3)
End If
Next i
Workbooks(FileName).Worksheets(datejour).Activate
Cells(2, ii + 31) = cel3
Next ii
'Attribution des codes segments Hotel 3 2eme page
For ii = 0 To 26
Workbooks(FileName).Worksheets(datejour).Activate
cel1 = Cells(3, ii + 60)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 4)
End If
Next i
Workbooks(FileName).Worksheets(datejour).Activate
Cells(2, ii + 60) = cel3
Next ii
'Attribution des codes segments Hotel 4 2eme page
For ii = 0 To 26
Workbooks(FileName).Worksheets(datejour).Activate
cel1 = Cells(3, ii + 89)
cel3 = "NA"
For i = 0 To 26
Workbooks(Classeur1).Worksheets("parametres").Activate
cel2 = Cells(i + 6, 1)
If cel1 = cel2 Then
cel3 = Cells(i + 6, 5)
End If
Next i
Workbooks(FileName).Worksheets(datejour).Activate
Cells(2, ii + 89) = cel3
Next ii
'------------------------------------------------------
'Copie des segments par regroupement du classeur Data Vers classeur Cales
Workbooks(Classeur1).Worksheets("HOTEL 1").Activate
Range("d7:m372").ClearContents
For i = 0 To 365 'compteur du tableau de synthese ligne
Workbooks(Classeur1).Worksheets("HOTEL 1").Activate
date1 = Cells(i + 7, 3)
For ii = 0 To 731 'compteur du tableau source ligne
Workbooks(FileName).Worksheets(datejour).Activate
date2 = Cells(ii + 4, 1)
If date1 = date2 Then
For iii = o To 9 'compteur tableau de synthese colone
Som = 0
Workbooks(Classeur1).Worksheets("HOTEL 1").Activate
cel1 = Cells(5, iii + 4)
For iiii = o To 26 'compteur tableau source colone
Workbooks(FileName).Worksheets(datejour).Activate
cel2 = Cells(2, iiii + 2)
If cel2 = cel1 Then
Som = Som + Cells(ii + 4, iiii + 2)
End If
Next iiii
Workbooks(Classeur1).Worksheets("HOTEL 1").Activate
Cells(i + 7, iii + 4) = Som
Next iii
End If
Next ii
Next i
'------------------------------------------------------
Application.ScreenUpdating = True
'------------------------------------------------------
'Somme du tableau se synthése
Workbooks(Classeur1).Worksheets("HOTEL 1").Activate
For i = o To 365
Som = 0
For ii = 0 To 9
Som = Som + Cells(i + 7, ii + 4)
Next ii
Cells(i + 7, 14) = Som
Next i
MsgBox ("travail terminé")
End Sub