0

Hello guys I'm here for a new question... For me, never seen like this before (Too misterious): Copy/Paste Data from temporary workbook 1 to a table in main workbook 2.

I'm making a code to copy a specific range (A2:B100) with raw data from a temporary workbook to paste in a table databodyrange (A22:B120) on the main workbook.

Here's the problem: 1st cell (in A2) in the copied range is not matching 1st cell in the table, but curiously, it misses the first 21 upper copied data rows.

This usually is very simple: Basically, On the main workbook, I 1st reset my table (by removing all databodyrange rows), and then go to the other workbook, copy the range and then come back to my main workbook, select the table and paste the data.

    Sub CopyPaste()

    'A few Variable declaration

    'Copying range from the Rawdata workbook
    Range(Cells(2, 1), Cells(2, 1).End(xlDown).Offset(0, 1)).Select
    Selection.Copy
    'Pasting range in the main workbook
    LibroPpal.Activate
    TablaDetalle.DataBodyRange.Select
    ActiveCell.Select
    ActiveSheet.Paste
    End Sub

I was expecting to paste exactly my selection.

AJ Suarez
  • 43
  • 8
  • Could it be a clue for you that the missing rows count (21) matches exactly the (21) rows over the table databodyrange? Why is it? How should I avoid this issue? – AJ Suarez Aug 14 '19 at 23:32
  • You really should fully qualify your Range/Cells objects with a sheet variable to avoid confusion like this instead of relying on which worksheet/workbook is active at the time. – braX Aug 15 '19 at 00:14
  • Also see [How to avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) and avoid using `Select`, `Selection`, `ActiveCell`, and `ActiveSheet`. – BigBen Aug 15 '19 at 02:01
  • Thank you guys. Thing is they really paste data. It's very strange, later below in my script, I copy the range in Column X to pasteit right beside the first range, and it pastes as if I had copied the Column C. It's kind of getting the data according to same column position... – AJ Suarez Aug 15 '19 at 02:32

0 Answers0