I have a macro that is used to fill in the "database" from the beginning so to say. Would like to use the same with the requested adjustments.
Sub Copy_To_Another_Workbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Change the file name (2*) and the path/file name to your file
If bIsBookOpen_RB("Formulär avvik.xls") Then
Set DestWB = Workbooks("avvik_database.xls")
Else
Set DestWB = Workbooks.Open(ThisWorkbook.Path & "\avvik_databas.xls")
End If
'Change the Source Sheet and range
Set SourceRange = ThisWorkbook.Sheets("Fyll i").Range("b13:g18")
'Change the sheet name of the database workbook
Set DestSh = DestWB.Worksheets("Blad1")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
'We make DestRange the same size as SourceRange and use the Value
'property to give DestRange the same values
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
DestWB.Close Savechanges:=True
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
Function LastCol(sh As Worksheet)
On Error Resume Next
LastCol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function
I hope that this helps.
Tomas