Copy from one spreadsheet to another

Asked

Viewed 24 times

-1

I am trying to perform this code but excel returns 1004 execution error on line 4 (marked **) could provide me some help on why this happens?

Dim i As Integer
For i = 0 To 367
    Sheets("Plan").Select
        If Cells(i, 1).Value = Date Then         **
             
            Sheets("Dólar").Range("B2").Copy
            Sheets("Plan1").Cells(i, 2).PasteSpecial xlPasteValues
            
        End If
     Next i
End Sub

1 answer

0

Do you want to copy the value in the correct cell ? From what I understand you only want to copy the value so you can use the following code:

For i = 0 To 367 step 1
    if Excel.Workbooks("nomeficheiro").Worksheets("List").Cells(i, 2).value = Date then
               Excel.Workbooks("nomeficheiro").Worksheets("List_2").Cells(i, 2) = Excel.Workbooks("nomeficheiro").Worksheets("List").Cells(i, 2)
             end if
 next
  • Excel.Workbooks("filename"). Worksheets("List"). Cells(i, 2). value -> value you want to copy
  • Excel.Workbooks("filename"). Worksheets("List_2"). Cells(i, 2) -> cell where you want to place the copied value. choose cell

Browser other questions tagged

You are not signed in. Login or sign up in order to post.