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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
| Sub mise_en_forme()
Dim LVL_Line, i, j, k, l As Integer, Insertion_Colonne As String, ColorCode
' insertion V5
Sheets("MEF").Select
Range("A5").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("MEF").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("MEF").Sort.SortFields.Add Key:=Range("A5"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("MEF").Sort
.SetRange Range("A5:C600")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
TypeConversion = MsgBox("Révision Article(OUI) ou Structure du Produit(NON) ?", vbYesNo, "Type ce conversion")
If TypeConversion = vbYes Then
Cells(2, 1).Value = "!IFS.COPYOBJECT"
Cells(3, 1).Value = "$LU=EngPartStructure"
Cells(4, 1).Value = "$VIEW=ENG_PART_STRUCTURE_EXT"
ElseIf TypeConversion = vbNo Then
Cells(2, 1).Value = "!IFS.COPYOBJECT"
Cells(3, 1).Value = "$LU=ProdStructure"
Cells(4, 1).Value = "$VIEW=PROD_STRUCTURE"
End If
' supression colonne A (lINE)
' Columns("B:C").Delete Shift:=xlToLeft
' format texte colonne
Range("D:E").NumberFormat = "00.0"
'conversion , en . pour avoir des nombres décimaux au lieu de mots au format 'string'
' Columns("G:G").Select
' Selection.Replace What:=",", Replacement:=".", lookat:=xlPart, _
' SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
' ReplaceFormat:=False
' définition hauteur et largeur du tableau
Range("A1").Select
Selection.End(xlDown).Select
Hauteur_Tableau = ActiveCell.Row
' calcul LVL_MAX et conversion des nombre 4 chiffres
' LVL_Max = 0
' For i = 2 To Hauteur_Tableau
' If Cells(i, 1).Value > LVL_Max Then LVL_Max = Cells(i, 1).Value
' If Len(Cells(i, 3).Value) < 5 Then
' Cells(i, 3).Value = "0" & Cells(i, 3).Value
' End If
' Next i
' LVL_Max = Val(LVL_Max)
' mise en forme tableau largeur hauteur cellule ajustées et bandeau 1ere ligne fixe
Rows("1:1").Select
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
Cells.Select
Cells.EntireColumn.AutoFit
Columns("I:I").Select
Selection.ColumnWidth = 50
Cells.EntireRow.AutoFit
Columns("A:Z").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Cells(1, 1).Select
Cells(1, 1).ColumnWidth = 60
Cells(1, 1).RowHeight = 150
'Cells(2, 8).Value = Hauteur_Tableau
' mise en forme données SEE
If TypeConversion = vbYes Then
For i = 5 To Hauteur_Tableau
j = Hauteur_Tableau - i + 6
If Len(Cells(j - 1, 1).Value) = 4 Then
Cells(j - 1, 1).Value = "0" & Cells(j - 1, 1).Value
End If
If Left(Cells(j - 1, 1).Value, 1) = "x" Or Left(Cells(j - 1, 1).Value, 1) = "X" Or Cells(j - 1, 1).Value = "N/A" Then
MsgBox ("Attention référence en XXXXX et/ou N/A, à codifier dans IFS et mettre à jour dans SEE")
initialisation
Exit Sub
End If
Rows("" & j & ":" & (j + 4) & "").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(j - 1, 4).Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]=""0"",RC[-1],RC[-1]*RC[-2]/1000)"
Cells(j, 1).Value = "$RECORD=!"
Cells(j + 1, 1).Value = "-$2:SUB_PART_NO=" & Cells(j - 1, 1).Value
Cells(j - 1, 5).FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC[-4],Tableau_dernière_revision_technique,2,FALSE))=TRUE, """",VLOOKUP(RC[-4],Tableau_dernière_revision_technique,2,FALSE))"
' "=IF(ISNA(VLOOKUP(RC[-4],Tableau_dernière_revision_technique[#All],2,FALSE))=TRUE, """",VLOOKUP(RC[-4],Tableau_dernière_revision_technique[#All],2,FALSE))"
If Cells(j - 1, 5).Value = "" Then Cells(j - 1, 5).Value = "A"
Cells(j + 2, 1).Value = "-$3:SUB_PART_REV=" & Cells(j - 1, 5).Value
Cells(j + 3, 1).Value = "-$6:POS=" & (i - 4)
Cells(j + 4, 1).Value = "-$7:QTY=" & Cells(j - 1, 4).Value
Rows("" & (j - 1) & ":" & (j - 1) & "").Select
Selection.Delete Shift:=xlUp
Next i
ElseIf TypeConversion = vbNo Then
For i = 5 To Hauteur_Tableau
j = Hauteur_Tableau - i + 6
If Len(Cells(j - 1, 1).Value) = 4 Then
Cells(j - 1, 1).Value = "0" & Cells(j - 1, 1).Value
End If
If Left(Cells(j - 1, 1).Value, 1) = "x" Or Left(Cells(j - 1, 1).Value, 1) = "X" Or Cells(j - 1, 1).Value = "N/A" Then
MsgBox ("Attention référence en XXXXX et/ou N/A, à codifier dans IFS et mettre à jour dans SEE")
initialisation
Exit Sub
End If
Rows("" & j & ":" & (j + 4) & "").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(j - 1, 4).Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]=""0"",RC[-1],RC[-2]/1000)"
Cells(j, 1).Value = "$RECORD=!"
Cells(j + 1, 1).Value = "-$6:COMPONENT_PART=" & Cells(j - 1, 1).Value
Cells(j + 2, 1).Value = "-$11:QTY_PER_ASSEMBLY=" & Cells(j - 1, 4).Value
Rows("" & (j - 1) & ":" & (j - 1) & "").Select
Selection.Delete Shift:=xlUp
Next i
End If
Range("A2:A" & 5 * (Hauteur_Tableau - 4) + 4 & "").Select
Range("A2:A" & 5 * (Hauteur_Tableau - 4) + 4 & "").Copy
MsgBox ("Les données sont disponibles pour l'ERP")
End Sub |
Partager