1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
Sub upd_flexi_fr_fr()
'Cette macro exporte tous les tarifs sous format exploitable par GW
'definitions
Dim wb As Workbook
Dim ws As Worksheet, wsprepa As Worksheet, wsoutput As Worksheet, wsto As Worksheet
Dim tbl(14, 2)
Dim plage As Range, resdate As Range
Dim indice As String, choix As String, chemin As String
Dim i As Integer, n As Integer
Dim T As Double
'attributions
tbl(0, 0) = "Z1 "
tbl(1, 0) = "Z2 "
tbl(2, 0) = "Z3 "
tbl(3, 0) = "Z4 "
tbl(4, 0) = "Z6 "
tbl(5, 0) = "Z8 "
tbl(6, 0) = "Z9 "
tbl(7, 0) = "Z10"
tbl(8, 0) = "Z11"
tbl(9, 0) = "Z12"
tbl(10, 0) = "Z13"
tbl(11, 0) = "Z14"
tbl(12, 0) = "Z15"
tbl(13, 0) = "Z16"
tbl(14, 0) = "Z17"
For i = 0 To 14
tbl(i, 1) = 0
Next i
tbl(0, 2) = "PE"
tbl(1, 2) = "AM"
tbl(2, 2) = "PI"
tbl(3, 2) = "RM"
tbl(4, 2) = "RA"
tbl(5, 2) = "WS"
tbl(6, 2) = "RP"
tbl(7, 2) = "RG"
tbl(8, 2) = "OR"
tbl(9, 2) = "PP"
tbl(10, 2) = "CD"
tbl(11, 2) = "PG"
tbl(12, 2) = "BO"
tbl(13, 2) = "TL"
tbl(14, 2) = "LR"
Set wb = Workbooks("macrofr_fr")
Set wsprepa = wb.Sheets("output")
wsprepa.Tab.ColorIndex = 4
Set wsto = wb.Sheets("tour operator")
Set resdate = wb.Sheets("Instructions").Range("resdate")
wsto.Range("E1") = resdate
Application.Dialogs(xlDialogOpen).Show
choix = InputBox("Creation d'un répertoire", "Nom du dossier contenant les exports à créer : ")
If choix = "" Then
MsgBox "Fin de la routine."
End
End If
chemin = "\\dossier\groups\automate\" & choix & " " & Left(Date, 2) & Mid(Date, 4, 2) & Mid(Date, 7, 4) & "\"
MkDir (chemin)
T = Timer
'boucle sur les onglets jaunes
For Each ws In Worksheets
If ws.Tab.ColorIndex = 6 And ws.Visible = True Or ws.Tab.ColorIndex = 27 And ws.Visible = True Then
indice = Left(ws.Name, 3)
For i = 0 To 14
If indice = tbl(i, 0) Then
tbl(i, 1) = tbl(i, 1) + 1
wsprepa.Copy Before:=wb.Sheets("tour operator")
ActiveSheet.Name = indice & " prepa " & tbl(i, 1)
Set wsoutput = ActiveSheet
wsoutput.Range("J7:M8").Value = ws.Range("AO252:AR253").Value
wsoutput.Range("F7").Value = ws.Range("AK252").Value
wsoutput.Range("E20:Z42").Value = ws.Range("AJ265:BE287").Value
End If
Next i
End If
Next ws
wsprepa.Tab.ColorIndex = 25
For Each ws In Worksheets
'recherche des dates + création csv
If ws.Tab.ColorIndex = 4 Then
Set plage = ws.Range("J8")
If plage < Date Or Left(plage, 2) = "AS" Then
wsto.Range("C1") = resdate
Else
wsto.Range("C1").Value = Left(plage, 2) & Mid(plage, 4, 2) & Right(plage, 2) & " 00:00"
End If
If Left(ws.Range("M8"), 2) = "NO" Then
wsto.Range("D1") = ""
Else
wsto.Range("D1") = Left(ws.Range("M8"), 2) & Mid(ws.Range("M8"), 4, 2) & Right(ws.Range("M8"), 2) & " 23:59"
End If
wsto.Range("E1") = Left(Date + 1, 2) & Mid(Date + 1, 4, 2) & Mid(Date + 1, 7, 4) & " 00:00"
For i = 0 To 21
Range(wsto.Cells(1 + i * 23, 7), wsto.Cells(23 + i * 23, 7)).Value = Range(ws.Cells(20, 5 + i), ws.Cells(42, 5 + i)).Value
Next i
indice = Left(ws.Name, 3)
n = Mid(ws.Name, 11, 1)
For i = 0 To 14
If indice = tbl(i, 0) Then
wsto.Copy
ActiveWorkbook.SaveAs (chemin & "STDF" & tbl(i, 2) & "FR" & n & ".csv"), FileFormat:=xlCSV, Local:=True, CreateBackup:=False
ActiveWindow.Close False
End If
Next i
End If
Next ws
'préparation des impressions
Application.DisplayAlerts = False
wsprepa.Delete
wsto.Delete
Sheets("instructions").Delete
wb.SaveAs (chemin & "Impressions.xls"), FileFormat:=xlNormal, CreateBackup:=FalseActive
MsgBox "Export effectué en " & Timer - T & " secondes"
Shell "explorer " & chemin, vbNormalFocus
wb.Close False
End Sub |
Partager