Re : Macro et glisser
Voici le code:
Sub Interpolation()
'
' Interpolation Macro
' Interpolation linéaire entre deux taux libor pour une date valeur donnée et sa durée de vie en jour.
'
'
Dim nbjexact As Integer
Dim nbjinf As Integer
Dim nbjsup As Integer
Dim txlibinf As Double
Dim txlibsup As Double
Dim DateValeur As Date
Dim txinterpol As Double
Dim i As Integer
i = 1
While i <> ActiveCell.Row
i = i + 1
Wend
nbjexact = Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("AQ" & i)
DateValeur = Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i)
If 1 <= nbjexact And nbjexact <= 7 Then
nbjinf = 1
nbjsup = 7
ElseIf 7 <= nbjexact And nbjexact <= 30 Then
nbjinf = 7
nbjsup = 30
ElseIf 30 <= nbjexact And nbjexact <= 60 Then
nbjinf = 30
nbjsup = 60
ElseIf 60 <= nbjexact And nbjexact <= 90 Then
nbjinf = 60
nbjsup = 90
Else
nbjinf = 90
nbjsup = 120
End If
If nbjinf = 1 Then
txlibinf = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsxm.xlsm").Sheets("Historique Libor aout").Range("A1:A100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("B1:B100"))
txlibsup = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsxm.xlsm").Sheets("Historique Libor aout").Range("D1
100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("E1:E100"))
ElseIf nbjinf = 7 Then
txlibinf = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("D1
100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("E1:E100"))
txlibsup = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("G1:G100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("H1:H100"))
ElseIf nbjinf = 30 Then
txlibinf = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("G1:G100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("H1:H100"))
txlibsup = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("J1:J100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("K1:K100"))
ElseIf nbjinf = 60 Then
txlibinf = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("$J$1:$J$100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("$K$1:$K$100"))
txlibsup = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("$M$1:$M$100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("$N$1:$N$100"))
Else
txlibinf = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsxm.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsxm.xlsm").Sheets("Historique Libor aout").Range("M1:M100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("N1:N100"))
txlibsup = WorksheetFunction.Lookup(Workbooks("Interpolation.xlsxm.xlsm").Sheets("PTF APPOLO").Range("I" & i), Workbooks("Interpolation.xlsxm.xlsm").Sheets("Historique Libor aout").Range("P1
100"), Workbooks("Interpolation.xlsm").Sheets("Historique Libor aout").Range("Q1:Q100"))
End If
txinterpol = (((txlibsup - txlibinf) * (nbjexact - nbjinf)) / (nbjsup - nbjinf)) + txlibinf
ActiveCell.FormulaR1C1 = txinterpol
End Sub
En fait le problème c'est que la personne qui utilisera la macro en question ne connais rien en vba, elle voudra donc surement executer la macro, puis faire un glisser jusqu'à la ligne qu'elle desirera. Bref elle ne saura pas intervenir sur le programme vba et donc ne saura pas capable de modifier la boucle que tu m'as proposé.
Suis-je assez clair ou auriez vous besoin d'autre explication ?