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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
| Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Dim c As Range
On Error GoTo errSelection
If Target.Validation.Type <> 0 Then
Set r = Range(Mid(Target.Validation.Formula1, 2))
For Each c In r.Cells
If c = Target Then
Range("D" & c.Row).Copy Range("D" & Target.Row)
Range("E" & c.Row).Copy Range("E" & Target.Row)
Range("G" & c.Row).Copy Range("G" & Target.Row)
Range("H" & c.Row).Copy Range("H" & Target.Row)
Range("J" & c.Row).Copy Range("J" & Target.Row)
Exit For
End If
Next c
End If
GoTo ext
errSelection:
Select Case Err.Number
Case 1004
Err.Clear
Case Else
MsgBox "erreur non prévue" & vbCrLf & "Erreur n°" & Err.Number & vbCrLf & _
Err.Description, vbCritical + vbOKOnly, "erreur"
Err.Clear
End Select
ext:
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim nligne As Integer
Dim Feuille As Worksheet
Dim CelluleRéférence As Range, CelluleIndex As Range, Cellulepointeur As Range
Set Feuille = Worksheets("FeuilleDeTravail")
Set CelluleRéférence = Feuille.Range("B4")
Set CelluleIndex = Feuille.Range("B5")
Set Cellulepointeur = Feuille.Range("B6")
nligne = CelluleRéférence.Value + CelluleIndex
'CREATION LIGNE
If Target.Row = nligne And Target.Column <= 4 Then
On Error GoTo errSelection
Bordure Range("A" & nligne + 1 & ":J" & nligne + 1)
CelluleIndex = CelluleIndex + 1
caseselect nligne + 1, 12
Cellulepointeur = Cellulepointeur + 1
lienext nligne
detailclient nligne
Target.Select
End If
GoTo exitfin
errSelection:
Select Case Err.Number
Case 1004
Err.Clear
Case Else
MsgBox "erreur non prévue" & vbCrLf & "Erreur n°" & Err.Number & vbCrLf & _
Err.Description, vbCritical + vbOKOnly, "erreur"
Err.Clear
End Select
exitfin:
End Sub
Sub Bordure(plage As Range)
plage.Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("F" & plage.Row).Formula = "=C" & plage.Row & "*E" & plage.Row
Range("I" & plage.Row).Formula = "=C" & plage.Row & "*H" & plage.Row
End Sub
Sub caseselect(nl As Integer, nldebut As Integer)
Range("B" & nl).Validation.Add Type:=xlValidateList, Formula1:="= B" & nldebut & ":B" & nl
Range("G" & nl).Validation.Add Type:=xlValidateList, Formula1:="='Indice Taux'!B5:B14"
Range("J" & nl).Validation.Add Type:=xlValidateList, Formula1:="='Indice Taux'!F5:F14"
End Sub
Sub lienext(i As Integer)
Dim c As Worksheet
Set c = Worksheets("Feuilledetravail")
c.Range("A" & i).FormulaR1C1 = "=Devis!R" & i & "C1"
c.Range("B" & i).FormulaR1C1 = "=Devis!R" & i & "C2"
c.Range("C" & i).FormulaR1C1 = "=Devis!R" & i & "C3"
c.Range("D" & i).FormulaR1C1 = "=Devis!R" & i & "C4"
c.Range("E" & i).FormulaR1C1 = "=Devis!R" & i & "C5"
c.Range("F" & i).FormulaR1C1 = "=Devis!R" & i & "C6"
c.Range("G" & i).FormulaR1C1 = "=Devis!R" & i & "C7"
c.Range("H" & i).FormulaR1C1 = "=Devis!R" & i & "C8"
c.Range("I" & i).FormulaR1C1 = "=Devis!R" & i & "C9"
c.Range("J" & i).FormulaR1C1 = "=Devis!R" & i & "C10"
c.Range("K" & i).FormulaR1C1 = "=IF(RC[-10]<>0,1,0)"
c.Range("L" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B5,F" & i & "*(1+ 'Indice Taux'!D5),)"
c.Range("M" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B6,F" & i & "*(1+ 'Indice Taux'!D6),)"
c.Range("N" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B7,F" & i & "*(1+ 'Indice Taux'!D7),)"
c.Range("O" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B8,F" & i & "*(1+ 'Indice Taux'!D8),)"
c.Range("P" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B9,F" & i & "*(1+ 'Indice Taux'!D9),)"
c.Range("Q" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B10,F" & i & "*(1+ 'Indice Taux'!D10),)"
c.Range("R" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B11,F" & i & "*(1+ 'Indice Taux'!D11),)"
c.Range("S" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B12,F" & i & "*(1+ 'Indice Taux'!D12),)"
c.Range("T" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B13,F" & i & "*(1+ 'Indice Taux'!D13),)"
c.Range("U" & i).Formula = _
"=IF(G" & i & "='Indice Taux'! B14,F" & i & "*(1+ 'Indice Taux'!D14),)"
c.Range("V" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F5,I" & i & "*('Indice Taux'!H5),)"
c.Range("W" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F6,I" & i & "*('Indice Taux'!H6),)"
c.Range("X" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F7,I" & i & "*('Indice Taux'!H7),)"
c.Range("Y" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F8,I" & i & "*('Indice Taux'!H8),)"
c.Range("Z" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F9,I" & i & "*('Indice Taux'!H9),)"
c.Range("AA" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F10,I" & i & "*('Indice Taux'!H10),)"
c.Range("AB" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F11,I" & i & "*('Indice Taux'!H11),)"
c.Range("AC" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F12,I" & i & "*('Indice Taux'!H12),)"
c.Range("AD" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F13,I" & i & "*('Indice Taux'!H13),)"
c.Range("AE" & i).Formula = _
"=IF(J" & i & "='Indice Taux'! F14,I" & i & "*('Indice Taux'!H14),)"
c.Range("AF" & i).Formula = _
"=SUM(L" & i & ":AE" & i & ")"
End Sub
Sub detailclient(i As Integer)
Dim a As Worksheet, b As Worksheet
Set a = Worksheets("Détail Client")
Set b = Worksheets("FeuilleDetravail")
a.Range("A" & i - 9).Formula = _
"=if('FeuilleDetravail'! A" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! A" & i & ")"
a.Range("B" & i - 9).Formula = _
"=if('FeuilleDetravail'! B" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! B" & i & ")"
a.Range("C" & i - 9).Formula = _
"=if('FeuilleDetravail'! C" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! C" & i & ")"
a.Range("D" & i - 9).Formula = _
"=if('FeuilleDetravail'! D" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! D" & i & ")"
a.Range("E" & i - 9).Formula = _
"=F" & i - 9 & "/C" & i - 9 & ""
If b.Range("B3") = 1 Then
a.Range("F" & i - 9).Formula = _
"=if('FeuilleDetravail'! AF" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! AF" & i & "* (1 + SommeMOBureau/SommeVenteBrute)*(1+coeffinal)*(1/(1+remise)))"
Else
a.Range("F" & i - 9).Formula = _
"=if('FeuilleDetravail'! AF" & i & "=0," & Chr(34) & Chr(34) & ",'FeuilleDetravail'! AF" & i & "*(1+coeffinal)*(1/(1+remise)))"
End If
If i > 13 Then
a.Range("G" & i - 10).Formula = _
"=if('FeuilleDetravail'! K" & i & "=0," & Chr(34) & Chr(34) & ",SUM(F3:F" & i - 10 & ")- SUM(G3:G" & i - 11 & "))"
End If
End Sub |
Partager