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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
|
Public Function AnalyseIS(ZoneIS As Range)
Dim tab_Pfcst(8) As Single, tab_Pact(8) As Single, tab_Pvar(8) As Single, tab_OPfcst(7) As Single, tab_OPact(7) As Single, tab_OPvar(7) As Single, xa As Double, xc As Integer
Dim monthS As String, yearS As Integer, typeS As String, i As Long, j As Long, k As Long
Dim MonGraphe As ChartObject, cumulP As Single, cumulOP As Single
monthS = sh_Actual.ComboBox1.Value
yearS = sh_Actual.ComboBox2.Value
typeS = sh_Actual.ComboBox3.Value
'---------------- Recherche la colonne contenant mon annee ------------------------------------------------------------------------------------
xa = WorksheetFunction.Match(sh_Actual.ComboBox2.Value, sh_Actual.Rows(8))
'---------------- me donne le numero du mois dans l'annee deduit du chiffre 1, ex avril = 4 - 1 = 3 --------------------------------------------
For i = 1 To sh_Data.Cells(1, 1).End(xlDown).Row
Select Case monthS
Case sh_Data.Cells(i, 1)
xc = i - 1
End Select
Next i
'---------------- Dans cette partie je definis mes tableaux variables qui vont me servir pour mes series dans mon graphique en fonction des valeurs dans mes ComboBox --------
For i = 1 To sh_Data.Cells(1, 3).End(xlDown).Row
Select Case typeS
Case sh_Data.Cells(i, 3)
tab_Pfcst(0) = sh_Actual.Cells(22, xa + 3 * xc) - sh_Actual.Cells(22, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1)
tab_Pact(0) = 0
For j = 1 To UBound(tab_Pfcst) - 1
tab_Pfcst(j) = sh_Actual.Cells(22 + j, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1) - Int(i / 3) * sh_Actual.Cells(22 + j, xa + 3 * xc + 2)
cumulP = 0
For k = 0 To j - 1
cumulP = cumulP + tab_Pfcst(k)
Next k
If tab_Pfcst(j) < 0 Then
tab_Pact(j) = cumulP + tab_Pfcst(j)
Else
tab_Pact(j) = cumulP
End If
Next j
tab_Pfcst(UBound(tab_Pfcst)) = 0
tab_Pact(UBound(tab_Pact)) = sh_Actual.Cells(22, xa + 3 * xc) - Int(i / 3) * sh_Actual.Cells(22, xa + 3 * xc + 2)
For k = 0 To UBound(tab_Pfcst)
tab_Pvar(k) = Abs(tab_Pfcst(k))
Next k
tab_OPfcst(0) = sh_Actual.Cells(33, xa + 3 * xc) - sh_Actual.Cells(33, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1)
tab_OPact(0) = 0
tab_OPfcst(1) = sh_Actual.Cells(17, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1) - Int(i / 3) * Cells(17, xa + 3 * xc + 2)
cumulOP = tab_OPfcst(0)
If tab_OPfcst(1) < 0 Then
tab_OPact(1) = cumulOP + tab_OPfcst(1)
Else
tab_OPact(1) = cumulOP
End If
cumulOP = tab_OPfcst(0) + tab_OPfcst(1)
For j = 0 To 2
tab_OPfcst(j + 2) = sh_Actual.Cells(18 + j, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1) - Int(i / 3) * sh_Actual.Cells(18 + j, xa + 3 * xc + 2)
'cumulOP = tab_OPfcst(0) + tab_OPfcst(1)
'For k = 0 To 2
'cumulOP = cumulOP - Int(k / 2 + 1 / 2) * tab_OPfcst(k + 1)
'Next k
If tab_OPfcst(j + 2) < 0 Then
tab_OPact(j + 2) = cumulOP
Else
tab_OPact(j + 2) = cumulOP - tab_OPfcst(j + 2)
End If
cumulOP = cumulOP - tab_OPfcst(j + 2)
Next j
tab_OPfcst(5) = sh_Actual.Cells(22, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1) - Int(i / 3) * sh_Actual.Cells(22, xa + 3 * xc + 2)
If tab_OPfcst(5) < 0 Then
tab_OPact(5) = cumulOP
Else
tab_OPact(5) = cumulOP - tab_OPfcst(5)
End If
tab_OPfcst(6) = sh_Actual.Cells(31, xa + 3 * xc + Int(Abs(Cos(i * 2 / 3)) * 2) + 1) - Int(i / 3) * sh_Actual.Cells(31, xa + 3 * xc + 2)
cumulOP = cumulOP - tab_OPfcst(5)
If tab_OPfcst(6) < 0 Then
tab_OPact(6) = cumulOP
Else
tab_OPact(6) = cumulOP - tab_OPfcst(6)
End If
tab_OPfcst(UBound(tab_OPfcst)) = 0
tab_OPact(UBound(tab_OPact)) = sh_Actual.Cells(33, xa + 3 * xc) - Int(i / 3) * sh_Actual.Cells(33, xa + 3 * xc + 2)
For k = 0 To UBound(tab_OPfcst)
tab_OPvar(k) = Abs(tab_OPfcst(k))
Next k
Case Else
End Select
Next i
'------------------- ici je realise ma mise en forme conditionnelle, en fonction des valeurs de mes tableaux variables qui servent series pour mon graph ---------------
sh_Actual.Activate
Set MonGraphe = sh_Actual.ChartObjects(1)
With Range(Cells(58, 3), Cells(62, 4))
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -395791
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = -395791
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
End With
With Range(Cells(58, 3), Cells(62, 3)).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
If ZoneIS.Value = sh_Actual.Cells(58, 3) Then
MonGraphe.Activate
With ActiveChart
.SeriesCollection(1).Values = tab_OPact
.SeriesCollection(2).Values = tab_OPvar
.SeriesCollection(1).XValues = "={""OP fcst"",""Net Sales"",""Frt"",""Pckg"",""Mat"",""Proc Cost"",""(to)/from"",""OP act""}"
With .SeriesCollection(2).Points(1).Format
With .Fill 'BLEU
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'BLEU FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
With .SeriesCollection(1).Points(2).Format
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End With
End With
If tab_OPfcst(1) < 0 Then
With ActiveChart.SeriesCollection(2).Points(2).Format
With .Fill 'ROUGE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'ROUGE FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
Else
With ActiveChart.SeriesCollection(2).Points(2).Format
With .Fill 'VERT
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
End With
With .Line 'VERT FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
End If
For i = 3 To UBound(tab_OPvar)
With ActiveChart.SeriesCollection(1).Points(i).Format
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End With
If tab_OPfcst(i - 1) < 0 Then
With ActiveChart.SeriesCollection(2).Points(i).Format
With .Fill 'VERT
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
End With
With .Line 'VERT FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
Else
With ActiveChart.SeriesCollection(2).Points(i).Format
With .Fill 'ROUGE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'ROUGE FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
End If
Next i
With ActiveChart.SeriesCollection(1).Points(UBound(tab_OPvar) + 1).Format
With .Fill 'BLEU
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'BLEU FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
Range(Cells(58, 3), Cells(58, 4)).Interior.Color = RGB(241, 245, 249)
Range(Cells(59, 3), Cells(62, 3)).Interior.Color = RGB(255, 255, 255)
Range(Cells(59, 4), Cells(62, 4)).Interior.Color = RGB(242, 242, 242)
With Range(Cells(58, 3), Cells(58, 3)).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(58, 3), Cells(58, 4)).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(58, 3), Cells(58, 3)).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -395791
.TintAndShade = 0
.Weight = xlThin
End With
With Range(Cells(58, 3), Cells(58, 3)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(59, 3), Cells(62, 3)).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(62, 4), Cells(62, 4)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
Range(Cells(59, 3), Cells(62, 3)).Borders(xlEdgeLeft).LineStyle = xlNone
Else
MonGraphe.Activate
With ActiveChart
.SeriesCollection(1).Values = tab_Pact
.SeriesCollection(2).Values = tab_Pvar
.SeriesCollection(1).XValues = "={""PC fcst"",""Empl"",""F.Energy"",""Atm"",""Util"",""Dep & Am"",""M.Rep & Sup"",""Others"",""PC act""}"
With .SeriesCollection(2).Points(1).Format
With .Fill 'BLEU
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'BLEU FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
End With
For i = 2 To UBound(tab_Pvar)
With ActiveChart.SeriesCollection(1).Points(i).Format
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End With
If tab_Pfcst(i - 1) < 0 Then
With ActiveChart.SeriesCollection(2).Points(i).Format
With .Fill 'VERT
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
End With
With .Line 'VERT FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
Else
With ActiveChart.SeriesCollection(2).Points(i).Format
With .Fill 'ROUGE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'ROUGE FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
End If
Next i
With ActiveChart.SeriesCollection(1).Points(UBound(tab_Pvar) + 1).Format
With .Fill 'BLEU
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0.400000006
.Transparency = 0
.Solid
End With
With .Line 'BLEU FONCE
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0
End With
End With
Range(Cells(62, 3), Cells(62, 4)).Interior.Color = RGB(241, 245, 249)
Range(Cells(58, 3), Cells(61, 3)).Interior.Color = RGB(255, 255, 255)
Range(Cells(58, 4), Cells(61, 4)).Interior.Color = RGB(242, 242, 242)
With Range(Cells(62, 3), Cells(62, 3)).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(62, 3), Cells(62, 3)).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(62, 3), Cells(62, 3)).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -395791
.TintAndShade = 0
.Weight = xlThin
End With
With Range(Cells(62, 3), Cells(62, 4)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(58, 4), Cells(61, 4)).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
With Range(Cells(58, 4), Cells(58, 4)).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
End If
'------------- ici ma tentative de deselectionner mon graph ----------------------------------------------------
ActiveChart.Deselect
sh_Actual.Cells(1, 1).Select
End Function |
Partager