I have a workbook: "Check for logging". From where I want to copy column "A" and paste it in workbook: "Unit test template". In column "A".
I have been trying to use following code:
Private Sub CopyColumnsButton_Click()
Dim sourceColumn As Range, targetColumn As Range
Set sourceColumn = Workbooks("Check for logging.xlsm").Worksheets("Parameters").Columns("A")
Set targetColumn = Workbooks("Unit test template.xlsm").Worksheets("Sheet1").Columns("A")
sourceColumn.Copy Destination:=targetColumn
End Sub
Though every time I attempt to run the macro, I get a message saying: "Run-time error '9': Subscript out of range" and then this line is highlighted:
Set targetColumn = Workbooks("Unit test template.xlsm").Worksheets("Sheet1").Columns("A")
Both workbooks are open when I attempt to run the macro.
I would be very thankfull if anyone could help