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
| Sub Test()
'
' Macro1 Macro
' Trie sur Chaine
'
Dim iRowL As Integer
iRowL = Cells(Rows.Count, 1).End(xlUp).Row
' Range("A4:S" & iRowL).Select
'
ActiveWorkbook.Worksheets("Test extract").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Test extract").Sort.SortFields.Add Key:=Range("B3:B376") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Test extract").Sort
.SetRange Range("A4:S" & iRowL)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Cells.Replace what:=",", Replacement:=".", lookat:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Dim nbOccurences As Integer
Dim RechercheFamille As String
' Boucle 07HA Debut
Range("A4").Select
RechercheFamille = Cells.Find(what:="07HA", After:=ActiveCell, LookIn:=xlFormulas, lookat _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
nbOccurences = Application.CountIf(Range("B4:B3000"), "07HA")
While nbOccurences > O
Selection.Offset(1, 0).Select
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.FillDown 'Range(LC + 1).Select
Selection.Offset(-1, 0).Select
' *********************************************************************************
' ActiveCell.FormulaR1C1 = "=R[1]C-1" 'modif du jours
ActiveCell.FormulaR1C1 = "=WORKDAY.INTL(R[1]C-1,-1,1,Fermeture[Date])"
' *********************************************************************************
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = "=RC[4]/RC[5]" 'formule nombre de barre pour l'of
Selection.NumberFormat = "0.000"
Selection.Offset(0, 5).Select 'déplacement Colonne +5 histo Range("H264").Select
ActiveCell.FormulaR1C1 = "=R[1]C*2" 'nbre de pc par barre x2
Selection.Offset(1, -6).Select 'Range("B265").Select
ActiveCell.FormulaR1C1 = "3"
Selection.Offset(1, 0).Select 'Range("B266").Select
nbOccurences = nbOccurences - 1
Wend
' Fin Boucle 07HA
End Sub |
Partager