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
|
Sub EXTRACT_Ticket_Layout()
With wsticket
'===============================================================
'%%%%%%%%%%%%%%%%%%%%%%% Paramétrisation %%%%%%%%%%%%%%%%%%%%%%%
rtickcol = .Cells.Find(What:="INC00*", SearchOrder:=xlByRows).Offset(-1, 0).row
If .Cells(rtickcol, 1) = "" Or wsticket.Cells(rtickcol, 1) Is Nothing Then
ctickfirst = .Cells(rtickcol, 1).End(xlToRight).Column
Else
ctickfirst = 1
End If
cticklast = .Cells(rtickcol, ctickfirst).End(xlToRight).Column
'===============================================================
'===============================================================
'%%%%%%%%%% Suppression des colonnes et lignes vides %%%%%%%%%%%
If Not rtickcol = 1 Then
For i = rtickcol - 1 To 1 Step -1
.Rows(i).Delete Shift:=xlUp
Next i
rtickcol = 1
End If
If Not ctickfirst = 1 Then
For i = ctickfirst - 1 To 1 Step -1
.Columns(i).Delete Shift:=xlToLeft
Next i
cticklast = cticklast - ctickfirst + 1
ctickfirst = 1
End If
'===============================================================
'===============================================================
'%%%%%%%%%%%%%% Défusion de toutes les cellules %%%%%%%%%%%%%%%%
With .Cells
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'===============================================================
'===============================================================
'%%%%%%%%%%%%%%% Concaténation sur une cellule %%%%%%%%%%%%%%%%%
cticknumber = .Cells.Find(What:="INC00*", SearchOrder:=xlByRows).Offset(-1, 0).Column
rtickend = .Cells(65536, cticknumber).End(xlUp).Offset(1, 0).row - 1
itickpre = rtickend
iticknext = .Cells(rtickend + 1, cticknumber).End(xlUp).row
'tant qu'on est pas au dernier avis
While Not iticknext = rtickcol
'si il y a des lignes vides à concaténer
If Not iticknext = itickpre Then
For i = itickpre To iticknext + 1 Step -1
For j = ctickfirst To cticklast
If Not (.Cells(i, j) Is Nothing Or .Cells(i, j) = "") Then
'si il y a un signe égal on passe en format texte
If Not InStr(.Cells(i, j), "=") = 0 Then
.Cells(i, j).NumberFormat = "@"
End If
If Not (.Cells(i - 1, j) Is Nothing Or .Cells(i - 1, j) = "") Then
If Not InStr(.Cells(i - 1, j), "=") = 0 Then
.Cells(i - 1, j).NumberFormat = "@"
End If
.Cells(i - 1, j) = .Cells(i - 1, j) & Chr(10) & .Cells(i, j)
Else
.Cells(i - 1, j) = .Cells(i, j)
End If
If .Cells(i - 1, j).NumberFormat = "@" Then
.Cells(i - 1, j).NumberFormat = "General"
End If
End If
Next j
.Rows(i).Delete
Next i
End If
itickpre = iticknext - 1
If .Cells(itickpre, cticknumber) Like "INC00*" Then
iticknext = itickpre
Else
iticknext = .Cells(iticknext, cticknumber).End(xlUp).row
End If
Wend
rtickend = .Cells(65536, cticknumber).End(xlUp).Offset(1, 0).row - 1
'=============================================================== |
Partager