Afficher plusieurs valeurs sur une ligne vide après saisie de données
l
Bonjour à tous
Au début, j'ai un tableau quasiment vide.
Je cherche à remplir automatiquement ligne après ligne mon tableau.
L'objectif est de voir le montant net de rentabilité après-taxe par session de trading.
1] Voir fichier xlsm ci-dessous
2] Voir image tout en bas | Voir code ci-dessous
Option Explicit
Sub compute_tax_crypto()
Worksheets("Sheet1").Activate
Dim number_of_session As Single
Dim cash_in As Single
Dim profit_or_loss As Single
Dim account_balance As Single
Dim cash_out As Single
Dim end_session_profit_or_loss_before_tax As Single
Dim tax_percentage As Single
tax_percentage = 30
Dim end_session_profit_or_loss_after_tax As Single
Dim i As Integer
i = 1
Dim last_row As Long
last_row = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, 1).End(xlUp).Row
number_of_session = InputBox("How many sessions did you trade?")
Cells(last_row + 1, 1) = number_of_session
Do Until i > number_of_session
Cells(1, 8) = i
i = i + 1
cash_in = InputBox("How many cash-in?")
Cells(last_row + 1, 2).Value = cash_in
profit_or_loss = InputBox("How many profit or loss?")
Cells(last_row + 1, 3).Value = profit_or_loss
account_balance = cash_in + profit_or_loss
Cells(last_row + 1, 4).Value = account_balance
Do
cash_out = VBA.InputBox("How many cash out?")
Loop Until cash_out <= account_balance
MsgBox "The amount of cash out is under amount of account balance, great!"
Cells(last_row + 1, 5).Value = cash_out
end_session_profit_or_loss_before_tax = cash_out - (cash_in * (cash_out / account_balance))
Cells(last_row + 1, 6).Value = end_session_profit_or_loss_before_tax
If Cells(last_row + 1, 6).Value <= 0 Then
Cells(last_row + 1, 7).Value = 0
MsgBox "The end session profit or loss after tax is : " & 0
Else
end_session_profit_or_loss_after_tax = (tax_percentage / 100) * end_session_profit_or_loss_before_tax
Cells(last_row + 1, 7).Value = end_session_profit_or_loss_after_tax
MsgBox "The end session profit or loss after tax is : " & end_session_profit_or_loss_after_tax
End If
Loop
End Sub
l
Merveilleux!!!!!!!
Merci infiniment!!!