Untitled

 avatar
unknown
vbscript
a year ago
1.2 kB
6
Indexable
Sub ajouter_button()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim nextEmptyRow As Long
    
    Set ws = ThisWorkbook.Sheets("Nom_de_votre_feuille") ' Remplacez "Nom_de_votre_feuille" par le nom de votre feuille
    
    If Range("K8") = "" Or Range("K9") = "" Or Range("K10") = "" Or Range("K11") = "" Or Range("K12") = "" Then
        MsgBox ("Des informations manquantes")
    Else
        ' Recherche de la dernière ligne utilisée dans la colonne B
        lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
        
        ' Trouver la prochaine ligne vide dans la colonne B
        If lastRow < 10 Then
            nextEmptyRow = 10
        Else
            nextEmptyRow = lastRow + 1
        End If
        
        ' Ajouter les valeurs des cellules K9 à K12 au tableau commençant à la ligne nextEmptyRow
        ws.Cells(nextEmptyRow, "B").Value = Range("K9").Value
        ws.Cells(nextEmptyRow, "C").Value = Range("K10").Value
        ws.Cells(nextEmptyRow, "D").Value = Range("K11").Value
        ws.Cells(nextEmptyRow, "E").Value = Range("K12").Value
        
        MsgBox ("Valeurs ajoutées avec succès.")
    End If
End Sub
Editor is loading...
Leave a Comment