Advertisement
YasserKhalil2019

T3973_Collate Data From Overtime Worksheets

Sep 23rd, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. https://excel-egy.com/forum/t3973
  2. ---------------------------------
  3.  
  4. Sub Collate_Data_From_Overtime_Worksheets()
  5. Dim aSheets(), aLast(), i%, x%, m%: m = 3
  6.  
  7. Application.ScreenUpdating = False
  8. For i = 3 To Sheets.Count
  9. x = i - 2
  10. ReDim Preserve aSheets(1 To x)
  11. ReDim Preserve aLast(1 To x)
  12. aSheets(x) = Sheets(i).Name
  13. aLast(x) = Application.Max(Sheets(i).Cells(Rows.Count, 1).End(xlUp).Row, 8) - 7
  14. Next i
  15.  
  16. With ThisWorkbook.Worksheets("ALL")
  17. .Range("A3").CurrentRegion.Offset(2).ClearContents
  18.  
  19. For i = LBound(aSheets) To UBound(aSheets)
  20. .Range("A" & m).Resize(aLast(i), 34).Value = Sheets(aSheets(i)).Range("A8").Resize(aLast(i), 34).Value
  21. m = m + aLast(i)
  22. Next i
  23. End With
  24. Application.ScreenUpdating = True
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement