2017-10-21 1 views
0

Ich arbeite in einer Arbeitsmappe mit zwei Blätter namens "Data" und "Daily". Ich möchte nur, dass mein Code neue Eingaben im Tagesblatt speichert, aber anstatt dies zu tun, speichert er das aktive Blatt. Ich bin dankbar, wenn jemand dieses Problem lösen kann.Wie kann ich vermeiden, dass meine Daten nicht auf dem aktiven Blatt gespeichert werden?

Hier ist mein Code:

Private Sub CommandButton1_Click() 'Saving Button 
    Dim sonsat As Long 

    sonsat = Sheets("Daily").Cells(Rows.Count, 1).End(xlUp).Row + 1 
    Call Main 'Progress Bar 

    Cells(sonsat, 1) = TextBox1 
    Cells(sonsat, 2) = TextBox2 
    Cells(sonsat, 3) = TextBox3 
    Cells(sonsat, 4) = TextBox4 
    Cells(sonsat, 5) = TextBox5 

    MsgBox "Registration is successful" 
    ListBox1.List = Sheets("Daily").Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row).Value 'For refresh listbox 
    TextBox14.Value = ListBox1.ListCount 
End Sub 

Antwort

1

Versuchen Bezug auf Tagesblatt auf diese Weise hinzuzufügen:

With Sheets("Daily") 
    .Cells(sonsat, 1) = TextBox1 'dot at the beginning is very important... 
    .Cells(sonsat, 2) = TextBox2 
    .Cells(sonsat, 3) = TextBox3 
    .Cells(sonsat, 4) = TextBox4 
    .Cells(sonsat, 5) = TextBox5 
end with 
+0

danke Liebe :) – Yasir

Verwandte Themen