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
|
Public Sub checkconsolidation()
Dim i As Integer
Dim nbligne As Integer
Dim myvalue As String
Dim val1 As String
Dim sum1 As Double
Dim val2 As String
Dim sum2 As Double
Dim rowdebut As Integer
Dim myformule As String
Application.DisplayAlerts = False
myformule = "=VLOOKUP(A:A;'H:\My Documents\inter\Thoms\[VlookupConso EURODOC Mar 2007.xls]Sheet1'!$A$4:$I$113;9;FALSE)"
Debug.Print myformule
nbligne = ActiveSheet.UsedRange.Rows.Count
Debug.Print nbligne
For i = 2 To nbligne
myvalue = Replace(Cells(i, 1).Value, " ", "")
Debug.Print myvalue
If Len(myvalue) = 2 Or Len(myvalue) = 3 Then
myvalue = Replace(Cells(i, 1).Value, ".", "")
Debug.Print myvalue
Cells(i, 1).Value = CInt(myvalue)
End If
Debug.Print myformule
' MsgBox myformule
If Len(Cells(i, 1).Value) >= 1 And Len(Cells(i, 1).Value) <= 4 Then
Debug.Print Len(Cells(i, 1).Value)
Debug.Print Cells(i, 1).Value
Cells(i, 11).FormulaLocal = myformule
'Cells(i, 11).Formula = myformule
Cells(i, 12).Value = "=K" & i & "*F" & i
Debug.Print Cells(i, 12).Value
End If
If Cells(i, 2) = "Price position" Then
rowdebut = i
Debug.Print rowdebut
End If
Next i
'-------mise en page-------'
Cells(rowdebut, 11).Value = "PRIX CONTRAT"
Cells(rowdebut, 11).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Columns.AutoFit
Cells(rowdebut, 12).Value = "TOTAL"
Cells(rowdebut, 12).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Columns.AutoFit
'----------------------'
'---------SUM----------'
Cells(nbligne + 5, 10).Value = "=SUM(J" & rowdebut & ":J" & nbligne & ")"
Cells(nbligne + 5, 12).Value = "=SUM(L" & rowdebut & ":L" & nbligne & ")"
Cells(nbligne + 4, 12).Value = "TOTAL"
Cells(nbligne + 4, 12).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Cells(nbligne + 5, 12).Select
Selection.NumberFormat = "#,##0.00"
Selection.Columns.AutoFit
Cells(nbligne + 4, 13).Value = "DIFFERENCE"
Cells(nbligne + 4, 13).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Columns.AutoFit
Cells(nbligne + 5, 13).Value = "=L" & (nbligne + 5) & "-" & "J" & (nbligne + 5)
Cells(nbligne + 5, 13).Select
Selection.NumberFormat = "#,##0.00"
'----------------------'
MsgBox ("It's done")
End Sub |