Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub BtnCompleter()
- '
- ' BtnCompleter Macro
- ' Complete une facture
- '
- '
- Dim cellule As Integer
- Dim valeurRech As Integer
- Dim quantite As Integer
- Dim total As Double
- Dim bol As Boolean
- Dim quantiteMaxAtteinte As Boolean
- cellule = 26 'compte
- bol = IsEmpty(Cells(cellule, 3))
- While bol = False
- If IsEmpty(Cells(cellule, 3)) = False Then
- valeurRech = Cells(cellule, 4) 'Ajuster la valeur a rechercher
- End If
- feuillePiece = Cells(cellule, 3) 'Ajuster dans quel feuille on va chercher
- 'Description
- Cells(cellule, 5).Value = "=VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,2)"
- quantite = Cells(cellule, 2)
- 'Verifier si la quantité en stock est suffisante
- If (quantite > Evaluate("=VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,4)")) Then
- MsgBox ("La quantité en stock est insuffisante.")
- quantiteMaxAtteint = True
- End If
- If quantiteMaxAtteint = False Then
- 'Prix unité si rabais 0%
- If ((Cells(20, 4) = "Non") And (Cells(20, 5) = "Non")) Then
- Cells(cellule, 9).Value = "=VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5)"
- End If
- 'Prix unité si rabais 5%
- If ((Cells(20, 4) = "Oui") And (Cells(20, 5) = "Non")) Then
- Cells(cellule, 9).Value = "=SUM(-VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5) * 0.05,VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5))"
- End If
- 'Prix unité si rabais 10%
- If ((Cells(20, 4) = "Non") And (Cells(20, 5) = "Oui")) Then
- Cells(cellule, 9).Value = "=SUM(-VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5) * 0.1,VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5))"
- End If
- 'Prix unité si rabais 15%
- If ((Cells(20, 4) = "Oui") And (Cells(20, 5) = "Oui")) Then
- Cells(cellule, 9).Value = "=SUM(-VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5) * 0.15,VLOOKUP(" & valeurRech & ",'" & feuillePiece & "'!A:E,5))"
- End If
- 'Prix total pour un type de piece
- Cells(cellule, 10).Value = quantite * Cells(cellule, 9)
- End If
- cellule = cellule + 1 'ajouter compteur de boucle
- bol = IsEmpty(Cells(cellule, 3)) 'Verifier si la prochaine cellule est vide
- Wend
- Range("J52") = Evaluate("=SUM(J26:J51)")
- Range("J53") = Evaluate("=J52*.05")
- Range("J54") = Evaluate("=J52*.095")
- Range("J55") = Evaluate("=SUM(J54:J52)")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement