Hi, Marianne Rachmann,
maybe you could have shown us your code.
Please adjust the drive and folder as well as maybe the fileformat for the workbook (here: xls). The code goes into ThisWorkbook of the workbook holding "Payment received":
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim wbRep As Workbook
Dim wsRep As Worksheet
Dim lngFirst As Long
Dim lngLast As Long
On Error Resume Next
Set wbRep = Workbooks("Reports.xls")
On Error GoTo 0
If wbRep Is Nothing Then
Set wbRep = Workbooks.Open("E:\Reports.xls")
End If
Set wsRep = wbRep.Sheets("Record of payments")
With wsRep
lngFirst = .Cells(Rows.Count, "A").End(xlUp).Row + 1
End With
With ThisWorkbook.Sheets("Payment received")
lngLast = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("A" & lngLast).Resize(1, 4).Copy wsRep.Cells(lngFirst, "A")
End With
'comment next line out if workbook should be closed
wbRep.Close savechanges:=True
Set wsRep = Nothing
Set wbRep = Nothing
End Sub
Ciao,
Holger
Bookmarks