bonjour
j'ai une macro de lettrage et je voudrais l'adapter comme suit:
soit deux colonnes a et b
dans la colonne A un chiffre ou montant
dans la colonne B plusieurs chiffres dont la somme de certain d'eux peuvent être égale a un chiffre de la colonne a
dans ce cas mettre zéro ces chiffres de la colonne a et b

comment adapter ce macro?
MERCI

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
Sub Lettrage()
 
Dim i As Integer
Dim j As Integer
Dim K As Integer
Dim Deb As String * 1
Dim Cre As String * 1
Dim Fac As String * 1
Dim DL As Integer
 
i = 2
j = 2
K = 0
Deb = InputBox("Introduire nom colonne debit :")
Cre = InputBox("Introduire nom colonne credit :")
Fac = InputBox("Introduire nom colonne facture :")
DL = CInt(InputBox("Introduire numero dernière ligne :"))
 
Do While i <= DL
j = 2
K = 0
Do While j <= DL And K = 0
If Range(Deb & i).Value = Range(Cre & j).Value And Range(Fac & i).Value = Range(Fac & j).Value Then
Range(Deb & i).Value = 0
Range(Cre & j).Value = 0
K = 1
End If
j = j + 1
Loop
i = i + 1
Loop
 
End Sub