0

What I Have: I am copying data to one workbook sheet data in another workbook sheet following VBA code I did write When I run this its showing Application-defined error.

Workbooks(mainworkbook).Sheets(ws.Name).Range("A1").Value = Workbooks(dataworkbook).Sheets(ws.Name).Range(Cells(1, 1), Cells(clearrow, lcol1)).Value
0m3r
  • 12,286
  • 15
  • 35
  • 71
  • 2
    If you do it that way I think you will have to `.Resize` the target range to the size of the source range. `Copy` does not require that. – iDevlop Oct 30 '18 at 10:14
  • Any other alternate way to import that one workbook sheet data into another without using copy and paste – srivardhan kandike Oct 30 '18 at 10:17

1 Answers1

0

The cells are not fully qualified. See the added dots, they make a huge difference:

With Workbooks(dataworkbook).Sheets(ws.Name)
    Workbooks(mainworkbook).Sheets(ws.Name).Range("A1").Value = .Range(.Cells(1, 1), .Cells(clearrow, lcol1)).Value
End With

Similar issues:

Vityata
  • 42,633
  • 8
  • 55
  • 100