Basically I created an xlxs with three sheets, one with data, one with formulas and one with the output.
Data are represented in a table with 28 features for each registration number, I am trying to perform a For ... Next loop to copy one row of data from the sheet "Data" to the sheet "Calculations", then copy the output from the "Output" sheet to an other Excel file and then to skip to the next registration number.
The code I wrote should work this way
Sub CopyPaste()
registration_numbers = Sheets("Data").Range("b1").Value
Workbooks.Add
wkb = Morkbooks.Application.ActiveWorkbook.Name
Sheets.Application.ActiveSheet.Name="Results"
Sheets.Application.ActiveSheet.Range("a1:i1").Value = ThisWorkbook.Sheets("Output_prg").Range("a1:i1").Value
For i = 1 To registration_numbers
x = 1 + i
If ThisWorkbook.Sheets("Data").Cells(x, 1).Value <> "" Then
[ThisWorkbook.Sheets("Calculations").Range(Cells(3, 1), Cells(3, 29)).Value = ThisWorkbook.Sheets("Data").Range(Cells(2 + i, 1), Cells(2 + i, 29)).Value]
Workbooks("wkb").Sheets("Results").Range(Cells(1 + i, 1), Cells(1 + i, 9)).Value = ThisWorkbook.Sheets("Output").Range("a2:i2").Value
End If
Next i
End Sub
However when I try to run this simple code I receive "1004" run-time error, and the line of code under square brackets gets highlighted in the debug.
What am I doing wrong? How can I solve this issue?