0

I want to copy the G column from wb1 to the last cell available of column O in wb2, i implemented a macro but it displays the ERROR 6 OVERFLOW. I think that the cell counting is correct because that's what i want to know, not the whole column but correct me if i'm wrong.

    Private Sub C_C(File As String)

Dim Lcopy As Workbook
Dim LDestiny As Workbook
Dim Destiny As Worksheet
'--
Set LDestiny = ActiveWorkbook
Set Destiny = ActiveSheet
Set Lcopy = Workbooks.Open(File)


Sheets("RCC").Range("G2" & Sheets(1).Range("G" & Rows.Count).End(xlUp).row).Copy
MsgBox ("Copied")
Destiny.Range("O").SpecialCells(xlCellTypeLastCell).Column
MsgBox ("Dont do anything")


ActiveWorkbook.Close
End Sub

With LastRow

Private Sub C_C(File As String)

    Dim Lcopy As Workbook
    Dim LDestiny As Workbook
    Dim Destiny As Worksheet
    '--
    Set LDestiny = ActiveWorkbook
    Set Destiny = ActiveSheet
    Set Lcopy = Workbooks.Open(File)


    Sheets("ReporteCifrasControl").Range("G2" & Sheets(1).Range("G" & Rows.Count).End(xlUp).row).Copy
MsgBox ("Copied")
Destino.Range("O" & Destino.Range("O" & Rows.Count).End(xlUp).row + 1).PasteSpecial xlPasteValues
MsgBox ("Dont do anything")


    ActiveWorkbook.Close
    End Sub
Zerrets
  • 53
  • 1
  • 8
  • `Destino.Range("O").SpecialCells(xlCellTypeLastCell).Column` - what is that supposed to do? – BigBen Feb 19 '20 at 20:24
  • @BigBen Supposed to look for the last available cell of "O" column and paste the whole data from the G2 column in there. – Zerrets Feb 19 '20 at 20:29
  • See [this question](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba) for how to find the last row. – BigBen Feb 19 '20 at 20:29
  • @BigBen i have the copy/paste for the last row, that piece i have it above it but how do i find the last available cell ? i tried to make it work finding the last row but it doesn't paste anything, i can paste how i did it. – Zerrets Feb 19 '20 at 20:31
  • Don't use `xlCellTypeLastCell` - find the last row in column O. – BigBen Feb 19 '20 at 20:32
  • @BigBen edited the post and now has how to look for the last row, i tried to do it like that but doesn't paste anything. – Zerrets Feb 19 '20 at 20:35
  • 1
    `Sheets("ReporteCifrasControl").Range("G2:G" & Sheets(1).Range("G" & Rows.Count).End(xlUp).row).Copy` – BigBen Feb 19 '20 at 20:36
  • Thanks @BigBen smooth, worked perfectly – Zerrets Feb 19 '20 at 20:44

0 Answers0