Saisie dans deux classeurs distint (même nom de feuille)

Bonjour

Apparement le titre de mon post https://forum.excel-pratique.com/viewtopic.php?f=2&t=120224n'etait pas clair.

je cherche un moyen de valider mes données saisie dans l'userform1

dans le classeur actif

ET

dans le classeur QVT GLOBAL.xlsm a la premiere ligne vide.

MERCi de votre aide

Bonjour,

voici un exemple à adapter,

Set wk1 = ThisWorkbook
Set sh1 = wk1.Sheets("Feuil1")
rw1 = sh1.Cells(Rows.Count, "A").End(xlUp).Row + 1

Set wk2 = Workbooks("QVT GLOBAL.xlsm")
Set sh2 = wk2.Sheets("Feuil1")
rw2 = sh2.Cells(Rows.Count, "A").End(xlUp).Row + 1

sh1.Cells(1, rw1) = userform1.TextBox1.Value
sh2.Cells(1, rw2) = userform1.TextBox1.Value

Bonjour

Merci J'ai trouver une solution

Private Sub cbValid_Click()
Dim wb As Workbook
    Dim I%

    If cbxBD2.ListIndex = -1 Or lbxBD1.ListIndex = -1 Then
        MsgBox "Pas d'agent identifié !", vbCritical, "Erreur"
        cbxBD2.SetFocus: Exit Sub
    ElseIf TT1.ListIndex = -1 Then
        MsgBox "Aucun évènement défini !", vbCritical, "Erreur"
        TT1.SetFocus: Exit Sub
    End If '--------------------------------------
    Sheets("Synthese").Select
    ActiveSheet.Unprotect Password:="******"
    With [LstEv]
        lni = .Rows.Count
        .Cells(lni, 1) = EvNiv.Value
        .Cells(lni, 2).Resize(, 16).Value = Worksheets("BDD").Cells(lnBD, 1) _
         .Resize(, 16).Value
        For I = 1 To 13
            If Controls("TT" & I).Value <> "" Then
                Select Case I
                    Case 2, 7, 11
                        .Cells(lni, I + 17) = CDate(Controls("TT" & I).Value)
                        Case 5
                        .Cells(lni, I + 17) = Controls("TT5").Caption
                    Case Else
                        .Cells(lni, I + 17) = Controls("TT" & I).Value
                End Select
            End If
        Next I
    End With
    Set wb = Workbooks.Open("C:\Suivi des Situations global.xlsm") 'LIGNE A MODIFIER selon ou ce trouve le fichier
Sheets("Synthese").Activate
ActiveSheet.Unprotect Password:="*******"
With [LstEv]
        lni = .Rows.Count
        .Cells(lni, 1) = EvNiv.Value
        .Cells(lni, 2).Resize(, 16).Value = Worksheets("BDD").Cells(lnBD, 1) _
         .Resize(, 16).Value
        For I = 1 To 13
            If Controls("TT" & I).Value <> "" Then
                Select Case I
                    Case 2, 7, 11
                        .Cells(lni, I + 17) = CDate(Controls("TT" & I).Value)
                        Case 5
                        .Cells(lni, I + 17) = Controls("TT5").Caption
                    Case Else
                        .Cells(lni, I + 17) = Controls("TT" & I).Value
                End Select
            End If
        Next I
    End With
    cbFiche.Enabled = True
    cbValid.Enabled = False
    cbRéinit.Enabled = True
    MsgBox "Evénement Saisie", vbOKOnly + vbInformation, "INFORMATION"
      Unload UserForm1

        Application.DisplayAlerts = False
Workbooks("Suivi des Situations global.xlsm").Save
Workbooks("Suivi des Situations global.xlsm").Close
    Call Macro1

End Sub

Merci

Rechercher des sujets similaires à "saisie deux classeurs distint meme nom feuille"