Hi all.
Long time reader, first time poster.
First up, I'm a complete noob regarding VBA.
I've got, I hope, a small problem I hope you guys can help with.
I have 2 workbooks where I need to copy from one to the other.
First workbook is named Data.xls and second is named Statistik 2011.xls.
Data.xls contains 10 rows with data.
I am trying to copy data from worksheet1 -row 9 ("I") to Statistik 2011.xls if it fulfills a certain match.
I have, in the Data.xls, made a formula that takes todays date minus 7 days.
Now if the date in row 10 ("J" - Data.xls) is bigger or equal than todays date minus 7 then it should copy all the cells in row 9 ("I") to Statistik 2011.xls worksheet3 "Indtastningsark" - row 9 ("I") BUT it should check and find the last used cell in that row + 1 and insert the data it copied from Data.xls
I can't seem to find the "Add file button" but if anyone wants a copy of the 2 files please let me know.
I have look and read all around the net withuot finding exactly what I need, so I've tried to put different things together and giving it a twist of my own.
The code I've used is this:
Cheers and thanks in advance.
/Kenneth
Long time reader, first time poster.
First up, I'm a complete noob regarding VBA.
I've got, I hope, a small problem I hope you guys can help with.
I have 2 workbooks where I need to copy from one to the other.
First workbook is named Data.xls and second is named Statistik 2011.xls.
Data.xls contains 10 rows with data.
I am trying to copy data from worksheet1 -row 9 ("I") to Statistik 2011.xls if it fulfills a certain match.
I have, in the Data.xls, made a formula that takes todays date minus 7 days.
Now if the date in row 10 ("J" - Data.xls) is bigger or equal than todays date minus 7 then it should copy all the cells in row 9 ("I") to Statistik 2011.xls worksheet3 "Indtastningsark" - row 9 ("I") BUT it should check and find the last used cell in that row + 1 and insert the data it copied from Data.xls
I can't seem to find the "Add file button" but if anyone wants a copy of the 2 files please let me know.
I have look and read all around the net withuot finding exactly what I need, so I've tried to put different things together and giving it a twist of my own.
The code I've used is this:
Code:
Sub Copy()
Workbooks.Open Filename:="Statistik 2011.xls", UpdateLinks:=0
ThisWorkbook.Activate
x = 2
Do While Cells(x, 9) <> ""
If Cells(x, 9) >= Range("K1") Then
Worksheets("Ark1").Rows(x).Copy
Workbooks("Statistik 2011.xls").Activate
Worksheets("Indtastningsark").Activate
erow = Cells(Rows.Count, "I").End(xlUp).Offset(1, 0).Row
ActiveSheet.PasteSpecial Destination:=Worksheets("Indtastningsark").Rows(erow)
End If
ThisWorkbook.Activate
Worksheets("Ark1").Activate
x = x + 1
Loop
End Sub
Cheers and thanks in advance.
/Kenneth