Copy data from one Excel workbook to another

Viewed 33

I have created this piece of code, and I don't understand why I get an error

Subscript out of range

It dies when I try to set WsDest.

The two lines before I need, cause the destination file is optional, but the name of the sheet Excel file and sheet is always the same.

An example of what could be in W12 = "C:\Users\DKOMGOMG\Desktop\Etellerandet"

Sub Vopy_Paste_Below_Last_Cell()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim 1CopyLastRow As Long
Dim 1DestLastRow As Long
Dim strFolder As string, strFile As String

Set wsCopy = Activewoork.Worksheets("output")
StrFolder = ActiveSheet.Range("W12").Value
StrFile = Dir(StrFolder & "\blablalba.xlsm")
Set wsDest = Workbooks("strFile").Worksheets("Ark2")

After this I have more code of course, but this is where I get stranded.

Don't know if I did the strfolder and strfile wrong? Hope someone can help!

0 Answers
Related