Advertisement
YasserKhalil2019

T4043_Copy Data As Values From Closed Workbook

Oct 4th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. https://excel-egy.com/forum/t4043
  2. ---------------------------------
  3.  
  4. Sub Copy_Data_As_Values_From_Closed_Workbook()
  5. Dim wb As Workbook, ws As Worksheet, sh As Worksheet, m As Long, n As Long, x As Long
  6.  
  7. Application.ScreenUpdating = False
  8. Set wb = Workbooks.Open(ThisWorkbook.Path & "\boys.xlsx")
  9. Set ws = wb.Worksheets("Export 2")
  10. Set sh = ThisWorkbook.Worksheets("All Data")
  11. m = ws.Cells(Rows.Count, 1).End(xlUp).Row
  12. n = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
  13. x = ws.Range("B7:B" & m).Rows.Count
  14.  
  15. sh.Range("A" & n).Resize(x, 3).Value = ws.Range("B7").Resize(x, 3).Value
  16. sh.Range("K" & n).Resize(x, 6).Value = ws.Range("E7").Resize(x, 6).Value
  17.  
  18. wb.Close False
  19. Application.ScreenUpdating = True
  20. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement