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
| '
Open Recordset'
Set objMyRecordset.Source = objMyCmd
objMyRecordset.Open
Range("d2").Select
ActiveSheet.Range("d2").CopyFromRecordset objMyRecordset
' variable last existing line
Dim down_line
' Formulas to get material ID root
Range("B2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[4],8)"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=IF(MID(RC[3],9,1)=""_"",""WIP"","""")"
' Copy the formula for existing lines
Range("F2").Select
down_line = Selection.End(xlDown).Row
If down_line > 0 Then
Range(Cells(2, 2), Cells(down_line, 3)).Select
Selection.FillDown
End If
' copy values to avoid recalculing when filtering
Columns("B:C").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("H:H").Select
Application.CutCopyMode = False
Selection.NumberFormat = "0"
Columns("J:J").Select
Selection.NumberFormat = "0.0"
Selection.NumberFormat = "0"
' application filtre en fonction du statut des bobines
Range("B2:P2").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ET($o2=1;$P2=1)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
'Et je m'arête là
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("B2:P2").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$P2>1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("B2:P2").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=ET($o2>1;$P2=1)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599963377788629
End With
Selection.FormatConditions(1).StopIfTrue = False
If down_line > 0 Then
Range("B2:P2").Select
Selection.Copy
Range("B3:P" & down_line).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
Range("a2").Select |
Partager