Ist es via vba möglich einen kopierten Bereich in Mappe1(tabelle1) in Mappe2 (tabelle1) einzufügen und dann dort zu Speichern ohne das Mappe2 geöffnet ist?
Danke fürs lesen
Gruß
Christian
Sub sbSave()
Workbooks.Opoen "Pfad\Dateiname.xls"
ThisWorkbook.Sheets("Blattname").Range("DeinBereich").Copy Range(" _
ZielZelle")
ActiveWorkbook.Close True
End Sub
Das Makro muss in der Datei gespeichert werden, in dem die Daten stehen, die in die andere Datei eingefügt werden sollen.
Private Sub CommandButton1_Click()
Workbooks.Open "C:\Users\Spenski\Desktop\Test.xlsx"
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(1, 0) = Now()
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 1) = Now()
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 3) = TextBox1.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 4) = TextBox2.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 5) = TextBox6.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 6) = TextBox3.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 7) = TextBox7.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 8) = TextBox4.Text
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 9) = TextBox5.Text
If OptionButton1.Value = True Then
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 2) = "A"
End If
If OptionButton2.Value = True Then
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 2) = "B"
End If
If OptionButton3.Value = True Then
Sheets("tabelle1").Cells(65536, 1).End(xlUp).Offset(0, 2) = "C"
End If
ActiveWorkbook.Close True
End Sub
Private Sub CommandButton1_Click()
Dim lloNextRow As Long
Workbooks.Open "C:\Users\Spenski\Desktop\Test.xlsx"
With Sheets("tabelle1")
lloNextRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(lloNextRow, 1) = Now()
.Cells(lloNextRow, 2) = Now()
.Cells(lloNextRow, 4) = TextBox1.Text
.Cells(lloNextRow, 5) = TextBox2.Text
.Cells(lloNextRow, 6) = TextBox6.Text
.Cells(lloNextRow, 7) = TextBox3.Text
.Cells(lloNextRow, 8) = TextBox7.Text
.Cells(lloNextRow, 9) = TextBox4.Text
.Cells(lloNextRow, 10) = TextBox5.Text
If OptionButton1.Value = True Then
.Cells(lloNextRow, 3) = "A"
Else
If OptionButton2.Value = True Then
.Cells(lloNextRow, 3) = "B"
Else
If OptionButton3.Value = True Then
.Cells(lloNextRow, 3) = "C"
End If
End If
End If
End With
ActiveWorkbook.Close True
End Sub
lloNextRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
lloNextRow = .Cells(Rows.Count, AndereSpalte).End(xlUp).Row + 1