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 60 61 62 63 64 65 66 67 68 69 70 71
|
Sub addProduct()
On Error GoTo End_AddProduct
'-------------------------------------------------------------------------------------------------------------------
' INITIALISATION DES VARIABLES GLOBALES
'-------------------------------------------------------------------------------------------------------------------
Call initVar
'-------------------------------------------------------------------------------------------------------------------
' DECLARATIONS :
'-------------------------------------------------------------------------------------------------------------------
' Produits
Dim PDT_derLig, PDT_DerCol, OWNER_derLig, OWNER_derCol, As Integer
Dim nbPDT, nbOwner As Integer
'--------------------------------------------------------------------------------------------------------------------
' INITIALISATION DES VARIABLES GENERALES :
'-------------------------------------------------------------------------------------------------------------------
PDT_derLig = lastEmptyLine(ws_PDT, 2, "A") 'calcul de la dernière ligne vide
PDT_DerCol = lastEmptyColumn(ws_PDT, 1, 1) 'calcul de la dernière colonne vide
OWNER_derLig = lastEmptyLine(ws_OWNER, 2, "A") 'calcul de la dernière ligne vide
OWNER_derCol = lastEmptyColumn(ws_OWNER, 1, 1) 'calcul de la dernière colonne vide
'-------------------------------------------------------------------------------------------------------------------
' CREATION DES TABLEAUX
'-------------------------------------------------------------------------------------------------------------------
nbPDT = PDT_derLig - 2 'Nombre de produits en bdd
nbOwner = OWNER_derLig - 2 'Nombre de porteur
ReDim pdtTab(nbPDT, 5) 'redimensionnement du tableau des produits
ReDim ownerTab(nbOwner, 2) 'redimensionnement du tableau des porteurs
' Construction du tableau des produits
For i = 0 To nbPDT
pdtTab(i, 0) = ws_PDT.Range("A" & i + 2).Value ' ID
pdtTab(i, 1) = ws_PDT.Range("B" & i + 2).Value ' Type de produit
pdtTab(i, 2) = ws_PDT.Range("C" & i + 2).Value ' Famille Produit
pdtTab(i, 3) = ws_PDT.Range("D" & i + 2).Value ' Jointures produit
pdtTab(i, 4) = ws_PDT.Range("E" & i + 2).Value ' Jointures livrable
Next i
' Construction du tableau des porteurs
For i = 0 To nbOwner
ownerTab(i, 0) = ws_OWNER.Range("A" & i + 2).Value ' ID
ownerTab(i, 1) = ws_OWNER.Range("B" & i + 2).Value ' Porteur du KID
Next i
' Appel de l'IHM
SelectProduct.Show
' Récupération des informations user
MsgBox ("Produit de tête : " & choixPdt)
'MsgBox ("Produit lié : " & productToAdd(0))
GoTo End_AddProduct
'-----------------------------------------------------------------------------------------------------------------------
' Ré-initialisation des variables
'-----------------------------------------------------------------------------------------------------------------------
End_AddProduct:
Erase pdtTab
Erase kidTab
Erase ownerTab
Erase joinTabPdt
Erase joinTabKid
choixPdt = ""
Erase productToAdd
End Sub |
Partager