Bonjour, je cherche à afficher les valeurs de la session trading n°2 en dessous des valeurs des valeurs de la session de trading n°1 et ainsi de suite.
1] Mon fichier xlsm ci-dessous:
Compute tax cryptocurrency.xlsm
2] Ce que je souhaite faire
3] Mon code ci-dessous:
Merci de votre aide!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 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
Partager