Bonjour,
Je souhaite réafficher l'input box "How many cash in?" si l'utilisateur saisit un montant de cash_out supérieur à account_balance.
Comment faire? Merci.
Compute tax cryptocurrency.xlsm
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
58
59 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 irow As Single number_of_session = InputBox("How many sessions did you trade?") Range("A2").Value = number_of_session Do Until i >= number_of_session Cells(1, 8) = i i = i + 1 cash_in = InputBox("How many cash-in?") Range("B2").Value = cash_in profit_or_loss = InputBox("How many profit or loss?") Range("C2").Value = profit_or_loss account_balance = cash_in + profit_or_loss Range("D2").Value = account_balance cash_out = InputBox("How many cash out?") If cash_out > account_balance Then Sub DefaultMsgBox() MsgBox ("Cash out is too high compared to account_balance! Put a smaller cash out.") Return Else End Sub Range("E2").Value = cash_out end_session_profit_or_loss_before_tax = cash_out - (cash_in * (cash_out / account_balance)) Range("F2").Value = end_session_profit_or_loss_before_tax If Range("F2").Value <= 0 Then Range("G2").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 Range("G2").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
Partager