Problème de copie sur une Macro

br44

XLDnaute Impliqué
Bonjour à tout le forum ,

Voilà je revient vers vous pour un problème de copie sur une macro .

Dans le fichier ci-joint vous trouverez un tableau qui contient plusieurs colonnes.

est plusieurs feuilles mensuelles qui détail le tableau de la feuille "Saisie1" .

Mon problème est située au niveau du bouton "Enregistrement des factures en cours" ,Il ne colle pas les informations dans la feuille de destinations ?

Je voudrais envoyer grâce à ce bouton que les informations de la plage "B12:G12" + la cellule "B8" de la feuille "SAISIE1" vers la plage "V8:AB8" de l'une des feuilles mensuelles en mettant le Montant de la Facture correspondante en Bleu Gras en même temps.

Le tableau alimente 1 usf qui se déclenche grâce au bouton située sur la feuille "SAISIE1".

Pour valider une facture il faut procédé de la façon suivante :
1 ouvrir l'usf
2 choisir un Nom dans la liste "NOM CLIENT"
3 remplir les textBox allant de "N° de Chèque à N° de Bordreau"
4 Choisir un N° de facture dans la liste de Choix dans la partie "Facture en cours " (Chaque N° correspond à une facture mensuelle ,1er N° pour le mois de "Janvier" ,le 2ème pour "Février" ,ect...)
5 Appuyer sur le bouton "Somme Dûe " pour valider le paiement (le montant passe en bleu )
6 cliquer sur le Bouton "Validation facture en cours "
7 cliquer sur le bouton "enregistrement facture en cours"
8 cliquer sur le bouton "Quitter" situé en haut à gauche de l'usf pour le fermé .

A NOTER : lors de cette procédure aucun beug est signalé .

Espérant avoir été claire dans ma demande et mes explications et vous remerciant par avance pour le coup de main je vous dis à bientôt sur se fil . Amicalement BR44

P.S Si ma demande n'est pas claire où si vous avez des questions surtout n'hésiter pas à me le signaler .Amicalement Br44

Voici mon fichier :
Cijoint.fr - Service gratuit de dépôt de fichiers
 

br44

XLDnaute Impliqué
Re : Problème de copie sur une Macro

Bonjour à tous

Je me permets de vous recontacter pour vous dire que je n'est toujours pas résolu mon problème . ce dernier se situe au niveau du collage de la macro vers les feuilles mensuelles ,le résultat ne s'affiche pas ?

Pour vous aider je vous mets la macro qui à servie de base à celle déjà jointes
dans mon message prècèdant.

Cette version elle fonctionne mais j'ai été obligé de la modifier.

si vous avez une idée où cela peut bloquer je suis preneur. Vous remerciant par avance je vous dis à plus sur ce fil .

Code:
[COLOR="Blue"]Option Explicit[/COLOR] [COLOR="Green"]'Oblige à déclarer toutes les variables[/COLOR]
[COLOR="Green"]'Procédure pour la Liste de choix "Nom des Clients "[/COLOR]
[COLOR="Green"]'Déclare la variable A pour la "plage client"pour la feuille"SAISIE1"[/COLOR]
 [COLOR="Blue"] Private[/COLOR] A [COLOR="Blue"]As[/COLOR] Range
[COLOR="Green"]'Déclare la variable plage[/COLOR]
  [COLOR="Blue"]Private[/COLOR] plage[COLOR="Blue"] As[/COLOR] Range
[COLOR="Green"]'Déclare la variable Cel pour le "Nom Client"[/COLOR]
 [COLOR="Blue"] Private[/COLOR] Cel [COLOR="Blue"]As[/COLOR] Range
 [COLOR="Blue"] Private[/COLOR] C [COLOR="Blue"]As[/COLOR] Range '[COLOR="Green"]pour les N°factures impayées[/COLOR]
[COLOR="Green"]'Déclare la varible X[/COLOR]
  [COLOR="Blue"]Dim[/COLOR] X [COLOR="Blue"]As[/COLOR] Byte
  [COLOR="Blue"]Dim[/COLOR] y [COLOR="Blue"]As[/COLOR] Byte
 [COLOR="Blue"] Dim [/COLOR]Z [COLOR="Blue"]As[/COLOR] Byte
[COLOR="Green"]'Déclare les variables AS INTEGER[/COLOR]
 [COLOR="Blue"] Dim[/COLOR] NC [COLOR="Blue"]As[/COLOR] Integer, LNomClient[COLOR="Blue"] As [/COLOR]Integer
  [COLOR="Blue"]Dim[/COLOR] I [COLOR="Blue"]As[/COLOR] Integer, N[COLOR="Blue"] As [/COLOR]Integer
[COLOR="Green"]'Déclare la variable Lig[/COLOR]
  Dim Lig[COLOR="Blue"] A[/COLOR]s Long
[COLOR="Green"]'Déclare la varible colonne[/COLOR]
  [COLOR="Blue"]Dim[/COLOR] Col [COLOR="Blue"]As[/COLOR] Byte
 [COLOR="Blue"]Dim[/COLOR] NomCombobox [COLOR="Blue"]As [/COLOR]String
[COLOR="Blue"]Dim[/COLOR] CGlobal [COLOR="Blue"]As[/COLOR] Integer

[COLOR="Blue"]Private Sub[/COLOR] UserForm_Initialize()
[COLOR="Green"]'Initialise à l'ouvertue de l'UserFrom
'Création de la Liste de Choix"Nom des Clients
'On remplit la liste des Noms
'Définit la variable A Sheets("SAISIE1") est actif[/COLOR]
  [COLOR="Blue"]Set A [/COLOR]= Range("A12:A" & Range("A65536").End(xlUp).Row - 3)
  CGlobal = Cells(10, 255).End(xlToLeft).Column [COLOR="Green"]'montant global[/COLOR]
' [COLOR="Green"] 'On boucle sur toutes les cellules de la plage A[/COLOR]
' [COLOR="Blue"] For[/COLOR] X = 1 [COLOR="Blue"]To[/COLOR] 34
'  Col = 1 + 35 'Détermine le choix des colonnes[COLOR="Green"]
'[/COLOR][COLOR='Green"]'Redéfinit la variable A et l'unie avec la dernière colonnes du tableau[/COLOR]
'   [COLOR="Blue"]Set[/COLOR] A = Application.Union(A, Range(Cells(35, Col), Cells(65536, Col).End(xlUp)))
[COLOR="Green"]'Sort de la boucle[/COLOR]
'  [COLOR="Blue"]Next [/COLOR]X
'
[COLOR="Green"]'Alimentation de la listbox[/COLOR]
[COLOR="Blue"]With[/COLOR] Me.NomClient
.Clear
.ColumnCount = 3
.ColumnWidths = "50;50;30"
.Style = fmStyleDropDownList
[COLOR="Blue"]For Each[/COLOR] Cel In A [COLOR="Green"]'boucle sur toutes les cellules Cel de la plage A[/COLOR]
    .AddItem Cel.Value 'ajoute le nom du client(en colonne 0 de la listbox)
    [COLOR="Green"]'Ajout le montantGlobal (en colonne 1 de la listbox)
    'Prend en compte la listbox et ajout de la somme[/COLOR]
        .List(.ListCount - 1, 1) = Cells(Cel.Row, CGlobal).Text 'Value
   [COLOR="Green"] 'Mets au format monaitère de la somme affichée dans la textbox[/COLOR]
'        .Column(1, .ListCount - 1) = Format(.Column(1, .ListCount - 1), "#,##0.00 €")
   [COLOR="Green"] 'Mémorise le numéro de ligne[/COLOR]
        .List(.ListCount - 1, 2) = Cel.Row [COLOR="Green"]'index ligne[/COLOR]
    [COLOR="Green"] 'fin de la prise en compte de la listbox[/COLOR]
[COLOR="Blue"]Next[/COLOR] Cel [COLOR="Green"]'prochaine cellule Cel de la [COLOR="Blue"][COLOR="Black"]listbox[/COLOR][/COLOR][/COLOR]
[COLOR="Blue"]End With[/COLOR]



[COLOR="Green"]'Création pour les "Date de Saisies"[/COLOR]
[COLOR="Green"]' Affiche la date de saisie[/COLOR]
DateSaisie.Value = Sheets("SAISIE1").Range("B8").Value
 

[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] NomClient_Change() [COLOR="Green"]'On récupère le combobox1 "NomClient" pour modification[/COLOR]

[COLOR="Green"]'Définit la variable LNomClient,fait double emploi avec ligne lig déplacée
 'LNomClient = Cells.Find(NomClient.Value, LookIn:=xlValues).Row[/COLOR]
 
 [COLOR="Blue"]Lig [/COLOR]= NomClient.List(NomClient.ListIndex, (NomClient.ColumnCount - 1))

 Me.MontantGlobal.Value = Cells(Lig, 35).Value
[COLOR="Green"]'Mise au format de la TextBox1[/COLOR] "MontantGlobal"
 Me.MontantGlobal.Value = Format(Me.MontantGlobal, "#,##0.00 €")
[COLOR="Green"]'Définit la variable Lig[/COLOR]
'Lig = CLng(NomClient.List(NomClient.ListIndex, (NomClient.ColumnCount - 1)))
[COLOR="Green"]'Parametrage des autres ComboBox de la feuille "SAISIE1"[/COLOR]
[COLOR="Blue"]Cal[/COLOR]l remplircombo("NFacture", Lig, coldep, colder, pas, "SAISIE1")
[COLOR="Blue"]Call[/COLOR] remplircombo("NAnFacture1", Lig, coldep + off1, colder + off1, pas, "SAISIE1")
[COLOR="Blue"]Call[/COLOR] remplircombo("NAnFacture2", Lig, coldep + off2, colder + off2, pas, "SAISIE1")
[COLOR="Blue"]Call[/COLOR] remplircombo("NFactureUnique", Lig, coldep + off3, colder + off3, pas, "SAISIE1")
[COLOR="Green"]'Parametrage des autres ComboBox de la feuille "RECAP IMPAYER"[/COLOR]
[COLOR="Blue"]Call[/COLOR] remplircombo1("NFacture1", Lig, coldep1, colder1, pas1, "RECAP IMPAYER")
[COLOR="Blue"]Call [/COLOR]remplircombo1("AnFacture1", Lig, coldep1 + off4, colder1 + off4, pas1, "RECAP IMPAYER")
[COLOR="Blue"]Call[/COLOR] remplircombo1("AnFacture2", Lig, coldep1 + off5, colder1 + off5, pas1, "RECAP IMPAYER")
[COLOR="Blue"]Call[/COLOR] remplircombo1("FactureUnique", Lig, coldep1 + off6, colder1 + off6, pas1, "RECAP IMPAYER")

[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] remplircombo(nomcombo As String, £lig As Long, £coldep As Integer, £colder As Integer, £pas As Byte, NomFeuil As String)
[COLOR="Blue"]With[/COLOR] Me.Controls(nomcombo)
    .Clear

[COLOR="Green"]'Creé une boucle dans le tableau à partir de la colonne N°de facture de la feuille "SAISIE1"[/COLOR]
[COLOR="Blue"]For[/COLOR] X = £coldep [COLOR="Blue"]To[/COLOR] £colder [COLOR="Blue"]Step[/COLOR] £pas
            .AddItem Sheets(NomFeuil).Cells(£lig, X).Text
            .List(.ListCount - 1, 1) = Sheets(NomFeuil).Cells(£lig, X).Offset(0, 1)
           [COLOR="Blue"] If[/COLOR] Sheets(NomFeuil).Cells(£lig, X).Offset(0, 1).Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR] [COLOR="Green"]'Affect une couleur au départ[/COLOR]
               [COLOR="Green"] 'La facture à déjà été payée[/COLOR]
                .List(.ListCount - 1, 2) = "Payer"
           [COLOR="Blue"] Else[/COLOR]
               [COLOR="Green"] 'la facture est dûe[/COLOR]
                .List(.ListCount - 1, 2) = ""
          [COLOR="Blue"]  End If
Next X
       End With
End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] remplircombo1(nomcombo As String, £lig As Long, £coldep1 As Integer, £colder1 As Integer, £pas1 As Byte, nomfeuil1 As String)
[COLOR="Blue"]With[/COLOR] Me.Controls(nomcombo)
    .Clear

[COLOR="Green"]'Creé une boucle dans le tableau à partir de la colonne N°de facture de la feuille "RECAP IMPAYER"[/COLOR]
[COLOR="Blue"]For[/COLOR] y = £coldep1 [COLOR="Blue"]To[/COLOR] £colder1 [COLOR="Blue"]Step[/COLOR] £pas1
            .AddItem Sheets(nomfeuil1).Cells(£lig, y)
            .List(.ListCount - 1, 1) = Sheets(nomfeuil1).Cells(£lig, y).Offset(0, 1)
            [COLOR="Blue"]If[/COLOR] Sheets(nomfeuil1).Cells(£lig, y).Offset(0, 1).Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR] [COLOR="Green"]'Affect une couleur au départ[/COLOR]
               [COLOR="Green"] 'La facture à déjà été payée[/COLOR]
                .List(.ListCount - 1, 2) = "Payer"
            [COLOR="Blue"]Else[/COLOR]
               [COLOR="Green"] 'la facture est dûe[/COLOR]
                .List(.ListCount - 1, 2) = ""
         [COLOR="Blue"]   End If
Next y
       End With
End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] NFacture_Change()[COLOR="Green"] 'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call[/COLOR] Combochange(Me.NFacture, Me.MonFacture, Me.ToggleButton1)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] NAnFacture1_Change() [COLOR="Green"]'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call [/COLOR]Combochange(Me.NAnFacture1, Me.MonAnFacture1, Me.ToggleButton2)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] NAnFacture2_Change() [COLOR="Green"]'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call [/COLOR]Combochange(Me.NAnFacture2, Me.MonAnFacture2, Me.ToggleButton3)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] NFactureUnique_Change() [COLOR="Green"]'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call [/COLOR]Combochange(Me.NFactureUnique, Me.MonFactureUnique, Me.ToggleButton4)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] NFacture1_Change() [COLOR="Green"]'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call [/COLOR]Combochange1(Me.NFacture1, Me.MonFacture1, Me.ToggleButton5)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] AnFacture1_Change()[COLOR="Green"] 'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call [/COLOR]Combochange1(Me.AnFacture1, Me.Manfacture1, Me.ToggleButton6)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] AnFacture2_Change() [COLOR="Green"]'au changement dans la listbox[/COLOR]
[COLOR="Blue"]Call[/COLOR] Combochange1(Me.AnFacture2, Me.ManFacture2, Me.ToggleButton7)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] FactureUnique_Change() 'au changement dans la listbox
[COLOR="Blue"]Call [/COLOR]Combochange1(Me.FactureUnique, Me.MFactureUnique, Me.ToggleButton8)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] Combochange(Cb As MSForms.ComboBox, tb As MSForms.TextBox, TG As MSForms.ToggleButton)
    [COLOR="Blue"]If[/COLOR] Cb.ListIndex = -1 [COLOR="Blue"]Then Exit Sub[/COLOR]
   [COLOR="Blue"] If[/COLOR] Cb.List(Cb.ListIndex, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       tb.ForeColor = &HFF0000
        TG = [COLOR="Green"]True[/COLOR]
    [COLOR="Blue"]Else[/COLOR]
        tb.ForeColor = &HC0&
        TG = False
    [COLOR="Blue"]End If[/COLOR]
    tb.Value = Format(CCur(Cb.List(Cb.ListIndex, 1)), "#,##0.00 €")
[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub [/COLOR]Combochange1(Cb As MSForms.ComboBox, tb As MSForms.TextBox, TG As MSForms.ToggleButton)
   [COLOR="Blue"] If[/COLOR] Cb.ListIndex = -1 [COLOR="Blue"]Then Exit Sub[/COLOR]
    [COLOR="Blue"]If[/COLOR] Cb.List(Cb.ListIndex, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       tb.ForeColor = &HFF0000
        TG = True
   [COLOR="Blue"] Else[/COLOR]
        tb.ForeColor = &HC0&
        TG = False
    [COLOR="Blue"]End If[/COLOR]
    tb.Value = Format(CCur(Cb.List(Cb.ListIndex, 1)), "#,##0.00 €")
[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] CommandButton1_Click() [COLOR="Green"]'Bouton "VALIDATION FACTURES EN COURS"[/COLOR]
[COLOR="Green"] 'Je recherche la dernière ligne de la colonne "A" (NomClient)[/COLOR]
 [COLOR="Blue"]If[/COLOR] NomClient.Value = "" [COLOR="Blue"]Then Exit Sub[/COLOR]
Lig = CLng(NomClient.List(NomClient.ListIndex, (NomClient.ColumnCount - 1)))
[COLOR="Green"]'Je Selectionne la feuille du classeur consernée[/COLOR]
[COLOR="Blue"]With[/COLOR] Sheets("SAISIE1")
[COLOR="Green"]'Pour le Nom des clients
'Je rentre les données dans le tableau
 'Pour les N° de Chèques où de virement[/COLOR]
    .Range("B" & Lig).Value = NCheque.Value
    .Range("C" & Lig).Value = NVirement.Value
[COLOR="Green"] 'Pour le Montant des Chéques où de virement[/COLOR]
  [COLOR="Blue"]If[/COLOR] Montant.Value <> "" [COLOR="Blue"]Then[/COLOR] .Range("D" & Lig).Value = CCur(Montant.Value)
    
 [COLOR="Green"]'Je mets au format les TextBox[/COLOR]
'     Montant.Value = Format(Montant, "#,##0.00 €")
[COLOR="Green"] 'Pour la date des Chéques où de virement[/COLOR]
    .Range("E" & Lig).Value = Date1.Value
[COLOR="Green"] 'Pour la Banque[/COLOR]
    .Range("F" & Lig).Value = Banque.Value
[COLOR="Green"]'Pour le N° de bordereau[/COLOR]
    .Range("G" & Lig).Value = Nbordereau.Value
 'Je quitte le feuille sélectionnée
[COLOR="Blue"]End With[/COLOR]

[COLOR="Green"]'Je rentre le paiement des factures de la feuille "SAISIE1"[/COLOR]

 [COLOR="Green"]'Pour la combo Facture[/COLOR]
  [COLOR="Blue"]With[/COLOR] NFacture
[COLOR="Green"]'Balayer tous les items[/COLOR]
    [COLOR="Blue"]For[/COLOR] X = 0 [COLOR="Blue"]To[/COLOR] .ListCount - 1
[COLOR="Green"]'si l'item est "Payer"
'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
    [COLOR="Blue"]If [/COLOR]NFacture.List(X, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       Sheets("SAISIE1").Range("I" & Lig).Offset(, X * 9).Font.ColorIndex = 5 [COLOR="Green"]'bleu[/COLOR]
   [COLOR="Blue"]Else[/COLOR]
       Sheets("SAISIE1").Range("I" & Lig).Offset(, X * 9).Font.ColorIndex = 3 [COLOR="Green"]'Rouge[/COLOR]
   [COLOR="Blue"] End If[/COLOR]
  [COLOR="Blue"]Next X[/COLOR]
 
[COLOR="Green"]'Pour la combo AnnexeFacture1[/COLOR]
 [COLOR="Blue"]With[/COLOR] NAnFacture1
[COLOR="Green"]'Balayer tous les items[/COLOR]
   [COLOR="Blue"]For X [/COLOR]= 0 [COLOR="Blue"]To[/COLOR] .ListCount - 1
[COLOR="Green"]'si l'item est "Payer"
'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
  [COLOR="Blue"] If[/COLOR] NAnFacture1.List(X, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
      Sheets("SAISIE1").Range("K" & Lig).Offset(, X * 9).Font.ColorIndex = 5 'bleu
  [COLOR="Blue"] Else[/COLOR]
      Sheets("SAISIE1").Range("K" & Lig).Offset(, X * 9).Font.ColorIndex = 3 'Rouge
 [COLOR="Blue"]  End If
  Next X
End With
[/COLOR]
[COLOR="Green"]'Pour la Combo AnnexeFacture2[/COLOR]
 [COLOR="Blue"] With [/COLOR]NAnFacture2
[COLOR="Green"]'Balayer tous les items[/COLOR]
 [COLOR="Blue"] For[/COLOR] X = 0 To .ListCount - 1
[COLOR="Green"]'si l'item est "Payer"
'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
   [COLOR="Blue"]If[/COLOR] NAnFacture2.List(X, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
      Sheets("SAISIE1").Range("M" & Lig).Offset(, X * 9).Font.ColorIndex = 5 'bleu
   [COLOR="Blue"]Else[/COLOR]
      Sheets("SAISIE1").Range("M" & Lig).Offset(, X * 9).Font.ColorIndex = 3 'Rouge
  [COLOR="Blue"] End If
 Next X
End With[/COLOR]
 
[COLOR="Green"]'Pour la Combo Facture Unique[/COLOR]
  [COLOR="Blue"]With[/COLOR] NFactureUnique
[COLOR="Green"]'Balayer tous les items[/COLOR]
    [COLOR="Blue"]For[/COLOR] X = 0 To .ListCount - 1
'[COLOR="Green"]si l'item est "Payer"
'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
   [COLOR="Blue"] If[/COLOR] NFactureUnique.List(X, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       Sheets("SAISIE1").Range("O" & Lig).Offset(, X * 9).Font.ColorIndex = 5 [COLOR="Green"]'bleu[/COLOR]
   [COLOR="Blue"] Else[/COLOR]
       Sheets("SAISIE1").Range("O" & Lig).Offset(, X * 9).Font.ColorIndex = 3 [COLOR="Green"]'Rouge[/COLOR]
   [COLOR="Blue"] End If
   Next X
  End With
End With
[/COLOR]
[COLOR="Green"]'Je Sélectionne la feuille "SAISIE1"[/COLOR]
[COLOR="Blue"]With[/COLOR] Feuil1
[COLOR="Blue"]Se[/COLOR]t plage = .Range("H12:O16") [COLOR="Green"]'Définit la variable plage[/COLOR]
  .Range("B19").Value = ""
  [COLOR="Blue"]For Each[/COLOR] C[COLOR="Blue"] In[/COLOR] plage
    [COLOR="Blue"]If[/COLOR] C.Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR]
      .Range("B19") = .Range("B19") + C.Value
    [COLOR="Blue"]End If
  Next C
End With[/COLOR]
[COLOR="Blue"]With[/COLOR] Feuil1
[COLOR="Blue"]Set[/COLOR] plage = .Range("Q12:X16")
  .Range("C19").Value = ""
  [COLOR="Blue"]For Each[/COLOR] C [COLOR="Blue"]In[/COLOR] plage
    [COLOR="Blue"]If[/COLOR] C.Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR]
      .Range("C19") = .Range("C19") + C.Value
    [COLOR="Blue"]End If
  Next C
End With[/COLOR]
[COLOR="Blue"]With[/COLOR] Feuil1
[COLOR="Blue"]Set[/COLOR] plage = .Range("Z12:AG16")
  .Range("D19") = ""
  [COLOR="Blue"]For Each[/COLOR] C [COLOR="Blue"]In[/COLOR] plage
    [COLOR="Blue"]If[/COLOR] C.Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR]
      .Range("D19") = .Range("D19") + C.Value
   [COLOR="Blue"] End If
  Next C
  End With[/COLOR]
  
[COLOR="Blue"] End Sub[/COLOR]
[COLOR="Blue"]Private Sub [/COLOR]CommandButton4_Click() [COLOR="Green"]'Bouton "VALIDATION FACTURES IMPAYEES"[/COLOR]

[COLOR="Green"]'Je recherche la dernière ligne de la colonne "A" (NomClient)[/COLOR]
Lig = CLng(NomClient.List(NomClient.ListIndex, (NomClient.ColumnCount - 1)))

 [COLOR="Green"]'Je Selectionne la feuille du classeur consernée[/COLOR]
[COLOR="Blue"]With [/COLOR]Sheets("RECAP IMPAYER")
  [COLOR="Green"] 'Je rentre les données dans le tableau[/COLOR]
 [COLOR="Green"] 'Pour les N° de Chèques où de virement[/COLOR]
    .Range("K" & Lig).Value = NCheque.Value
[COLOR="Green"] 'Pour le Montant des Chéques où de virement[/COLOR]
    .Range("J" & Lig).Value = Montant.Value
 [COLOR="Green"]'Je mets au format les TextBox[/COLOR]
     Montant.Value = Format(Montant, "#,##0.00 €")
[COLOR="Green"] 'Pour la date des Chéques où de virement[/COLOR]
    .Range("L" & Lig).Value = Date1.Value
 [COLOR="Green"]'Pour la date de la saisies des Chéques où des virements[/COLOR]
    .Range("M" & Lig).Value = DateSaisie.Value
[COLOR="Green"] 'Pour la Banque[/COLOR]
    .Range("N" & Lig).Value = Banque.Value
[COLOR="Green"]'Pour le N° de bordereau[/COLOR]
    .Range("O" & Lig).Value = Nbordereau.Value
[COLOR="Green"]'Je quitte le feuille sélectionnée[/COLOR]
[COLOR="Blue"]End With[/COLOR]

[COLOR="Green"]'Je rentre le paiement des factures de la feuille "RECAP IMPAYER"
'Pour la combo Facture[/COLOR]
  [COLOR="Blue"] With [/COLOR]NFacture1
[COLOR="Green"]'Balayer tous les items[/COLOR]
   [COLOR="Blue"]For y[/COLOR] = 0 [COLOR="Blue"]To[/COLOR] .ListCount - 1
[COLOR="Green"]'si l'item est "Payer"[/COLOR]
[COLOR="Green"]'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
   [COLOR="Blue"]If [/COLOR]NFacture1.List(y, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       Sheets("RECAP IMPAYER").Range("C" & Lig).Offset(, y * 14).Font.ColorIndex = 5 [COLOR="Green"]'Bleu[/COLOR]
   Else
       Sheets("RECAP IMPAYER").Range("C" & Lig).Offset(, y * 14).Font.ColorIndex = 3 [COLOR="Green"]'Rouge[/COLOR]
   [COLOR="Blue"]  End If
  Next y
 End With[/COLOR]
[COLOR="Green"]'Pour la combo AnnexeFacture1[/COLOR]
 With AnFacture1
 [COLOR="Green"]'Balayer tous les items[/COLOR]
  [COLOR="Blue"] For[/COLOR] y = 0 [COLOR="Blue"]To[/COLOR] .ListCount - 1
[COLOR="Green"]'si l'item est "Payer"
'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
   [COLOR="Blue"]If [/COLOR]AnFacture1.List(y, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
      Sheets("RECAP IMPAYER").Range("E" & Lig).Offset(, y * 14).Font.ColorIndex = 5 [COLOR="Green"]'Bleu[/COLOR]
   [COLOR="Blue"]Else[/COLOR]
      Sheets("RECAP IMPAYER").Range("E" & Lig).Offset(, y * 14).Font.ColorIndex = 3[COLOR="Green"] 'Rouge[/COLOR]
  [COLOR="Blue"] End If
  Next y
End With[/COLOR]
[COLOR="Green"]'Pour la Combo AnnexeFacture2[/COLOR]
  [COLOR="Blue"]With [/COLOR]AnFacture2
[COLOR="Green"]'Balayer tous les items[/COLOR]
 [COLOR="Blue"]For y [/COLOR]= 0 [COLOR="Blue"]To [/COLOR].ListCount - 1
[COLOR="Green"] 'si l'item est "Payer"[/COLOR]
[COLOR="Green"]'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
       [COLOR="Blue"]If [/COLOR]AnFacture2.List(y, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       Sheets("RECAP IMPAYER").Range("G" & Lig).Offset(, y * 14).Font.ColorIndex = 5  'Bleu
    [COLOR="Blue"]Else[/COLOR]
       Sheets("RECAP IMPAYER").Range("G" & Lig).Offset(, y * 14).Font.ColorIndex = 3 'Rouge
     [COLOR="Blue"] End If[/COLOR]
 [COLOR="Blue"] Next y
  End With[/COLOR]
[COLOR="Green"] 'Pour la Combo Facture Unique[/COLOR]
  [COLOR="Blue"]With[/COLOR] FactureUnique
[COLOR="Green"] 'Balayer tous les items[/COLOR]
 [COLOR="Blue"] For y[/COLOR] = 0 To .ListCount - 1
 [COLOR="Green"]'si l'item est "Payer"
 'alors mettre couleur bleue dans la bonne colonne uniquement[/COLOR]
    [COLOR="Blue"]If[/COLOR] FactureUnique.List(y, 2) = "Payer" [COLOR="Blue"]Then[/COLOR]
       Sheets("RECAP IMPAYER").Range("I" & Lig).Offset(, y * 14).Font.ColorIndex = 5 'Bleu
    [COLOR="Blue"]Else[/COLOR]
       Sheets("RECAP IMPAYER").Range("I" & Lig).Offset(, y * 14).Font.ColorIndex = 3 'Rouge
   [COLOR="Blue"] End If
 Next y
End With[/COLOR]


[COLOR="Blue"]With[/COLOR] Feuil5
[COLOR="Blue"]Set[/COLOR] plage = .Range("B12:I16")
  .Range("B19").Value = ""
 [COLOR="Blue"] For Each[/COLOR] C [COLOR="Blue"]In [/COLOR]plage
   [COLOR="Blue"] If [/COLOR]C.Font.ColorIndex = 5[COLOR="Blue"] Then[/COLOR]
      .Range("B19") = .Range("B19") + C.Value
  [COLOR="Blue"]  End If
  Next C
End With[/COLOR]
[COLOR="Blue"]With[/COLOR] Feuil5
[COLOR="Blue"]Set plage[/COLOR] = .Range("P12:W16")
  .Range("C19").Value = ""
 [COLOR="Blue"] For Each[/COLOR] C [COLOR="Blue"]In[/COLOR] plage
    [COLOR="Blue"]If[/COLOR] C.Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR]
      .Range("C19") = .Range("C19") + C.Value
   [COLOR="Blue"] End If
  Next C
End With
With Feuil5[/COLOR]
[COLOR="Blue"]Set[/COLOR] plage = .Range("AD12:AK16")
  .Range("D19").Value = ""
  [COLOR="Blue"]For Each[/COLOR] C [COLOR="Blue"]In[/COLOR] plage
    [COLOR="Blue"]If[/COLOR] C.Font.ColorIndex = 5 [COLOR="Blue"]Then[/COLOR]
      .Range("D19") = .Range("D19") + C.Value
  [COLOR="Blue"]  End If
  Next C
End With
End Sub[/COLOR]
 
[COLOR="Blue"]Private Sub[/COLOR] CommandButton2_Click() 'Bouton "ENREGISTRER"
[COLOR="Green"]'Déclare la variable Mois[/COLOR]
 [COLOR="Blue"] Dim[/COLOR] Mois [COLOR="Blue"]As String[/COLOR]
  [COLOR="Blue"]Dim [/COLOR]k [COLOR="Blue"]As [/COLOR]Integer, L [COLOR="Blue"]As[/COLOR] Long, Col [COLOR="Blue"]As[/COLOR] Integer
[COLOR="Green"]'Déclare la variable B et C[/COLOR]
 [COLOR="Blue"] Dim[/COLOR] B [COLOR="Blue"]As[/COLOR] String
 [COLOR="Blue"] Dim[/COLOR] C [COLOR="Blue"]As[/COLOR] Range
  [COLOR="Green"]'changé de méthode,problème avec numfact,pourquoi???
  'nomcombobox contiendra nfacture,nanfacture1,etc[/COLOR]
[COLOR="Blue"]If[/COLOR] NomClient.Value = "" Or NomCombobox = ""[COLOR="Blue"] Then Exit Sub[/COLOR]
 L = NomClient.List(NomClient.ListIndex, 2)[COLOR="Green"] 'la ligne du nom[/COLOR]
[COLOR="Green"]'cherche le n°facture sur la ligne[/COLOR]
[COLOR="Blue"]With[/COLOR] Sheets("SAISIE1")
[COLOR="Blue"]Set[/COLOR] C = .Rows(L).Find(Controls(NomCombobox).Value, LookIn:=xlValues)
[COLOR="Blue"]If Not[/COLOR] C [COLOR="Blue"][COLOR="Blue"]Is Nothing Then[/COLOR]
[COLOR="Green"]'Définit la variable Mois[/COLOR]
[COLOR="Green"]'c.formula="=JANVIER!E9" ,InStr donne la position de ! dans la chaîne
'd'où mid(2,résultat instr-2) donne le mois voir aide(F1)[/COLOR]
Mois = Mid(C.Formula, 2, InStr(C.Formula, "!") - 2) 'extrait le mois
C.Offset(, 1).Font.ColorIndex = 5
C.Offset(, 1).Font.Bold = [COLOR="Green"]True[/COLOR]
Col = C.Column [COLOR="Green"]'colonne du mois[/COLOR]
[COLOR="Green"]'ModuleFonction contient SommeSiCouleur[/COLOR]
.Cells(L, Col + 8).Value = SommeSiCouleur(.Range(.Cells(L, Col + 1), .Cells(L, Col + 7)))  [COLOR="Green"] 'ligne mois[/COLOR]
[COLOR="Blue"]'Set[/COLOR] Plg = Application.Union(.Range("P" & L), .Range("Y" & L), .Range("AL" & L))
[COLOR="Green"]'.Cells(L, CGlobal).Value = SommeSiCouleur(Plg)
'.Cells(L, CGlobal).Value - .Cells(L, Col + 1).Value 'global[/COLOR]
Me.MontantGlobal = .Cells(L, CGlobal)
Me.NomClient.List(Me.NomClient.ListIndex, 1) = Me.MontantGlobal
[COLOR="Blue"]Else[/COLOR]: MsgBox "Pas trouvé n°facture": [COLOR="Blue"]Exit Sub
End If
End With[/COLOR]
L = 0
[COLOR="Green"]'cherche d'abord le nom,ensuite le n°facture sur la ligne[/COLOR]
[COLOR="Blue"]With Sheets(Mois)[/COLOR] 'si tu employes with end with ne pas oublier le point devant cells et /ou range
[COLOR="Blue"]Set[/COLOR] C = .Columns("B").Find(NomClient.Value, LookIn:=xlValues)
   [COLOR="Blue"]If Not[/COLOR] C [COLOR="Blue"]Is Nothing Then[/COLOR]
L = C.Row [COLOR="Green"]'index ligne nom[/COLOR]
[COLOR="Blue"]Set[/COLOR] C = .Rows(L).Find(Controls(NomCombobox).Value, LookIn:=xlValues)
[COLOR="Blue"]If Not[/COLOR] C [COLOR="Blue"]Is Nothing Then[/COLOR]
C.Offset(0, -1).Font.ColorIndex = 5
C.Offset(, -1).Font.Bold = True[COLOR="Green"] 'corrigé[/COLOR]
[COLOR="Green"]'si tu entres le tout en même temps
'Sheets("SAISIE1").Range("B" & Lig & ":G" & Lig).Copy Destination:=Sheets(Mois).Range("V" & C.Row)
 'aussi possible,sans format
 '.Range("V" & C.Row).Value = Sheets("SAISIE1").Range("B" & Lig).Value
 'copie tout y compris format[/COLOR]
    Sheets("SAISIE1").Range("B" & Lig).Copy Destination:=.Range("V" & C.Row) 'corrigé 7 lignes
   Sheets("SAISIE1").Range("C" & Lig).Copy Destination:=.Range("W" & C.Row)
   Sheets("SAISIE1").Range("D" & Lig).Copy Destination:=.Range("X" & C.Row)
   Sheets("SAISIE1").Range("E" & Lig).Copy Destination:=.Range("Y" & C.Row)
  Sheets("SAISIE1").Range("F" & Lig).Copy Destination:=.Range("Z" & C.Row)
  Sheets("SAISIE1").Range("G" & Lig).Copy Destination:=.Range("AA" & C.Row)
 Sheets("SAISIE1").Range("B8").Copy Destination:=.Range("AB" & C.Row)
 
[COLOR="Blue"] End If
 
 End If
End With[/COLOR]

[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] CommandButton3_Click() 'QUITTER
Unload Me
[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] ToggleButton1_Click()
[COLOR="Blue"]Call[/COLOR] ToggleButtonx(NFacture, MonFacture, ToggleButton1, ToggleButton1)
[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] ToggleButton2_Click()
[COLOR="Blue"]Call [/COLOR]ToggleButtonx(NAnFacture1, MonAnFacture1, ToggleButton2, ToggleButton2)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private[/COLOR] Sub ToggleButton3_Click()
[COLOR="Blue"]Call [/COLOR]ToggleButtonx(NAnFacture2, MonAnFacture2, ToggleButton3, ToggleButton3)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] ToggleButton4_Click()
[COLOR="Blue"]Call[/COLOR] ToggleButtonx(NFactureUnique, MonFactureUnique, ToggleButton4, ToggleButton4)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] ToggleButton5_Click()
Call ToggleButtonx(NFacture1, MonFacture1, ToggleButton5, ToggleButton5)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] ToggleButton6_Click()
[COLOR="Blue"]Call[/COLOR] ToggleButtonx(AnFacture1, Manfacture1, ToggleButton6, ToggleButton6)
[COLOR="Blue"]End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] ToggleButton7_Click()
[COLOR="Blue"]Call [/COLOR]ToggleButtonx(AnFacture2, ManFacture2, ToggleButton7, ToggleButton7)
[COLOR="Blue"] End Sub[/COLOR]
[COLOR="Blue"]Private Sub[/COLOR] ToggleButton8_Click()
[COLOR="Blue"]Call[/COLOR] ToggleButtonx(FactureUnique, MFactureUnique, ToggleButton8, ToggleButton8)
[COLOR="Blue"]End Sub[/COLOR]

[COLOR="Blue"]Private Sub[/COLOR] ToggleButtonx(Cb As MSForms.ComboBox, tb As MSForms.TextBox, TG1 As MSForms.ToggleButton, TG2 As MSForms.ToggleButton)
 
 [COLOR="Blue"]If[/COLOR] TG1 [COLOR="Blue"]Then[/COLOR]
        tb.ForeColor = &HFF0000
        TG2.Caption = "PAYER "
        [COLOR="Blue"]With[/COLOR] Cb
       [COLOR="Blue"] If [/COLOR].ListIndex > -1 And tb = Format(.List(.ListIndex, 1), "#,##0.00 €") [COLOR="Blue"]Then[/COLOR]
        NomCombobox = Cb.Name
           .List(.ListIndex, 2) = "Payer"
        [COLOR="Blue"]End If
        End With[/COLOR]
    [COLOR="Blue"]Else[/COLOR]
        TG1.Caption = "Somme Due"
        MFactureUnique.ForeColor = &HC0&
        [COLOR="Blue"]With[/COLOR] Cb
        If .ListIndex > -1 And tb = Format(.List(.ListIndex, 1), "#,##0.00 €") [COLOR="Blue"]Then[/COLOR]
           .List(.ListIndex, 2) = " Dûe "
        [COLOR="Blue"]End If
        End With
    End If[/COLOR]
    
[COLOR="Blue"]End Sub[/COLOR]
Code:
 

skoobi

XLDnaute Barbatruc
Re : Problème de copie sur une Macro

Bonsoir br44,

rien ne se copie car à aucun moment tu attribues une valeur à la variable NomCombobox, donc:

Code:
If NomClient.Value = "" Or [B]NomCombobox = ""[/B] Then [B]Exit Sub[/B]
 

br44

XLDnaute Impliqué
Re : Problème de copie sur une Macro

Bonjour Skoobi,le forum

Je te remercie pour cette réponse ainsi que pour ta rapidité.

Je suis désolé de te demander ,mais je n'est pas saisie le sens de ta réponse ?

Si tu voulait me dire que le ligne de code que tu ma donnée est fausse dans se cas là je serais surpris car la macro que j'ai déposée hier fonctionne et existe dans les deux versions .

Si non les valeurs sont déclarées de la manière suivante:
Code:
[COLOR="Blue"]If[/COLOR] NomClient.Value = "" [COLOR="Blue"]Or[/COLOR] NomCombobox = "" [COLOR="Blue"]Then Exit Sub[/COLOR]
 L = NomClient.List(NomClient.ListIndex, 2) [COLOR="Green"]'la ligne du nom[/COLOR]
[COLOR="Green"]'cherche le n°facture sur la ligne[/COLOR]
[COLOR="Blue"]With[/COLOR] Sheets("SAISIE1")
[COLOR="Blue"]Set[/COLOR] C = .Rows(L).Find([COLOR="Red"]Controls(NomCombobox).Value,[/COLOR] LookIn:=xlValues)

L=Nomclient
pour le NomCombobox je te le signal en rouge dans le code .

Te remerciant d'avance je te dit à plus sur se fil .Amicalement Br44
 

skoobi

XLDnaute Barbatruc
Re : Problème de copie sur une Macro

Re bonjour br44,

Si je mets un point d'arrêt dans le code du Bouton "ENREGISTREMENT FACTURE EN COURS" et que je suis la procédure donné dans ton premier message pour la saisie, au moment de l'enregistrement tu pourras constaté que:
Code:
NomCombobox = ""
Donc:
Code:
Exit Sub
puisque la condition est remplie.

Dans le code que tu as joints au deuxième message, cette variable va bien à un moment donné prendre une valeur ici:

Code:
Private Sub ToggleButtonx(Cb As MSForms.ComboBox, tb As MSForms.TextBox, TG1 As MSForms.ToggleButton, TG2 As MSForms.ToggleButton)
 
 If TG1 Then
        tb.ForeColor = &HFF0000
        TG2.Caption = "PAYER "
        With Cb
        If .ListIndex > -1 And tb = Format(.List(.ListIndex, 1), "#,##0.00 €") Then
       [COLOR=Blue][B] NomCombobox = Cb.Name[/B][/COLOR]
           .List(.ListIndex, 2) = "Payer"
        End If
        End With
mais pas dans ton nouveau code...

A te relire.
 

br44

XLDnaute Impliqué
Re : Problème de copie sur une Macro

Bonsoir Skoobi,le forum


Comme prévu dans mon dernier message d'hier ,je te mets au courant à la suite de mes testes .

Le résultat n'est point celui escompter ,oui en effet j'ai maintenant un beug au niveau de la lignes suivante:
Code:
Set C = .Rows(L).Find(Controls(NomCombobox).Value, LookIn:=xlValues)

Le message qui s'affiche est le suivant :

Erreur d'exécution:'-2147024809
Objet Spécifié introuvable

De plus en regardant de plus prés je me suis aperçu que la suite du code va beugué lui aussi puisqu'il y a "la variable du bloc With n'est pas définit"

Est que la variable C est en Nothing quand je passe la souris dessus .

Si tu peut me donnée une petite explication sur se problème cela m'aiderais peut-être à le régler .

Te remerciant par avance du coup de main ,je te dis à bientôt .Amicalement BR44
 

skoobi

XLDnaute Barbatruc
Re : Problème de copie sur une Macro

Bonjour br44,

Qu'as-tu modifié dans ton code?
Qu'est devenu la variable NomCombobox?
Si tu passes dessus lors de l'execution tu verras qu'elle est vide:
Code:
NomCombobox = ""
On tourne en rond là...
 

br44

XLDnaute Impliqué
Re : Problème de copie sur une Macro

Bonjour Skoobi ,le forum

Je te remercie pour ta réponse .

Pour que l'on travail sur le même fichier je te joint la version poster dans mon premier message avec les modifications suivante :

1) est rajouter :

Code:
NomCombobox = Cb.Name
Comme tu me la dis dans la partie "ToggleButtonx "

pour la déclaration NomCombobox elle est bien déclarer dans la partie "Option explicit "

En se qui concerne le beug j'ai réussi à régler le problème en rajoutant ceci
Code:
If Not C Is Nothing Then
Juste après le With "SAISIE1"

Après avoir tester plusieurs fois le résultat est le même je n'est toujours pas d'affichage dans la feuille mensuelle sélectionnée (ici "JANVIER" pour l'exemple) .

Voici le lien pour le fichier
Cijoint.fr - Service gratuit de dépôt de fichiers

En conclusion je ne voie pas où sa peut bloquer ?

Maintenant si tu as une autre solution pour résoudre le problème je suis preneur .

Te remerciant par avance pour tout je te dis à plus .Amicalement Br44
 

Discussions similaires

Statistiques des forums

Discussions
312 188
Messages
2 086 028
Membres
103 100
dernier inscrit
erym64300