Modification du Code VBA

Bonjour le forum

J'ai un soucis dans l'userform1

Private Sub CmdB_Modifier_Click()

    If MsgBox("Etes-vous certain de vouloir modifier ce produit ?", _
             vbYesNo, "Demande de confirmation") = vbYes Then
        Dim Ligne As Long
        Dim i As Integer

           If Me.ComboBox2.ListIndex = -1 Then Exit Sub
           Ligne = Me.ComboBox2.List(Me.ComboBox2.ListIndex, 1)
           For i = 11 To 15
               If Me.Controls("TextBox" & i).Visible = True Then
                   Ws.Cells(Ligne, i - 4) = Me.Controls("TextBox" & i)
              End If
           Next i
           For i = 17 To 21
               If Me.Controls("TextBox" & i).Visible = True Then
                   Ws.Cells(Ligne, i - 2) = Me.Controls("TextBox" & i)
              End If
           Next i
    End If
End Sub

Quand je fais modifier, je pars à la 4ème Colonne et il rajoute une colonne supplémentaire

Le code est totalement décaler

Je souhaite qu'il modifie de la colonne A-E et de G-K

Cordialement

Laurent

9produit-forum.xlsm (215.07 Ko)

Bonsoir le forum

Je n'ai pas resolu le premier sujet et j'accrois l'erreur avec ceci:

Private Sub UserForm_Initialize()        ' ----- à l'initialisation de l'userform

    Dim i As Integer
    'Oter la barre dans l'userform
    OteTitleBarre Me.Caption, False        ' --- True pour le remettre

    Set Ws = Worksheets("PRODUIT")
    NbLignes = Ws.Range("A65536").End(xlUp).Row

    With Me.ComboBox2
        .ColumnCount = 2        ' -------------- 2 colonnes
        .ColumnWidths = "-1;0"        ' -------- Dont une de masquée
    End With

    InitComboBox1        ' --------------------- Lance le programme Init

     For i = 2 To Ws.Range("E65536").End(xlUp).Row
         ComboBox3 = Ws.Range("E" & i)
        If ComboBox3.ListIndex = -1 Then ComboBox3.AddItem Ws.Range("E" & i)
    Next i

    Me.ComboBox3.List = ListSort(Me.ComboBox3.List)

    ' ========== Format des TextBox ==========
    TextBox2 = Format(TextBox2, "# ##0.00€")
    TextBox3 = Format(TextBox3, "# ##0%")
    TextBox4 = Format(TextBox4, "# ##0.00€")
    TextBox6 = Format(TextBox6, "# ##0.00Kg")
    TextBox14 = Format(TextBox14, "# ##0.00€")
    TextBox15 = Format(TextBox15, "# ##0%")
    TextBox16 = Format(TextBox16, "# ##0.00€")

End Sub

et j'ai une autre erreur dans le module filtre

Sub ItemsUniquesBDD()
    Sheets("PRODUIT").Select
    Application.ScreenUpdating = False
    ' Déclaration d'une nouvelle collection
    Dim NoDupes As New Collection
    ' Sélection de la plage à traiter
    A = Range([A2], [A65536].End(xlUp)).Value
    [A1].Select
    ' Désactivation du gestionnaire d'erreurs
    On Error Resume Next
    ' Boucle pour récupérer la collection d'items uniques
    For j = 1 To UBound(A, 1)
        NoDupes.Add A(j, 1), CStr(A(j, 1))
    Next j
    ' Réactivation du gestionnaire d'erreurs
    On Error GoTo 0
    ' Récupération des items uniques
    For i = 1 To NoDupes.Count
        Cells(i + 1, 15).Value = NoDupes(i)
    Next i
End Sub

Merci cordialement

Laurent

11produit-forum.xlsm (224.69 Ko)
Rechercher des sujets similaires à "modification code vba"