The following Code works fine in my Sheet 1. But I want to transfer data from one sheet into an other.
Sub Data_Transfer()
Dim rowcount As Integer
Sheets("Eingabe").Select ' Whatever your sheet is
rowcount = 4
rowcount = Application.CountA(Range("A:A")) + 1 'get end range
ActiveSheet.Unprotect 123
Cells(5, 2).Select 'select the start cell
'autofill to rowcount
Selection.AutoFill Destination:=Range("B5:B" & rowcount), Type:=xlFillDefault
ActiveSheet.Protect 123
End Sub
How is the syntax for the Destination? I tried:
Set fillRange = Worksheets("MDB_to_pA_Dispodaten").Range("B5:B" & rowcount)
Selection.AutoFill Destination:=fillRange, Type:=xlFillDefault
But it doesn't work...
EDIT: --> The AutoFill method of the Range object cannot be executed. Error 1004
EDIT 2: What I need is this:
Sub Daten_Transfer()
Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A5:X33").Select
Selection.Copy
Sheets("MDB_to_pA_Dispodaten").Select
Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
End Sub
But I need it dynamicly! Because on times the user have 33 rows in the first sheet, next day he has 10 rows. I want only transfer the filled rows from Sheet 1 into Sheet 2, because Sheet 2 is a link table to MS Access.