Hello!
I have some problems with pasting values from one sheet to another.
This is my code:
Public Sub SaveCSV()
Dim sPath As String, sFilename As String, sPath_and_filename As String, start_date As String, end_date As String, data_cell As String
Dim i As Integer, j As Integer, n As Integer, row_start_date As Integer, row_end_date As Integer
n = Cells(65536, 1).End(xlUp).Row
With Sheets("Data selection")
start_date = .Cells(2, 4).Value
end_date = .Cells(3, 4).Value
For i = 15 To n
If .Cells(i, 1).Value = start_date Then
row_start_date = i
End If
If .Cells(i, 1).Value = end_date Then
row_end_date = i
End If
Next i
For i = 2 To 30
Range(Cells(row_start_date, i), Cells(row_end_date, i)).Select
Selection.Copy
Sheets("opt_input").Cells(1, i).Paste
Next i
End with
I get the error msg "Object doesn't support this property or method", highlighting "Sheets("opt_input").Cells(1, i).Paste".
What am I doing wrong?
Thanks.
I have some problems with pasting values from one sheet to another.
This is my code:
Public Sub SaveCSV()
Dim sPath As String, sFilename As String, sPath_and_filename As String, start_date As String, end_date As String, data_cell As String
Dim i As Integer, j As Integer, n As Integer, row_start_date As Integer, row_end_date As Integer
n = Cells(65536, 1).End(xlUp).Row
With Sheets("Data selection")
start_date = .Cells(2, 4).Value
end_date = .Cells(3, 4).Value
For i = 15 To n
If .Cells(i, 1).Value = start_date Then
row_start_date = i
End If
If .Cells(i, 1).Value = end_date Then
row_end_date = i
End If
Next i
For i = 2 To 30
Range(Cells(row_start_date, i), Cells(row_end_date, i)).Select
Selection.Copy
Sheets("opt_input").Cells(1, i).Paste
Next i
End with
I get the error msg "Object doesn't support this property or method", highlighting "Sheets("opt_input").Cells(1, i).Paste".
What am I doing wrong?
Thanks.