dufusgoofus
New Member
- Joined
- Feb 25, 2024
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
Hello. VBA noob here. Learning on-the-fly to solve an issue.
---------------
The Issue
---------------
The Question
---------------
Partial VBA
---------------
With wsSource
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastCol = .Cells(Columns.Count).End(xlToLeft).Column
Set rgSource = .Range(.Cells(2, 1), .Cells(LastRow, LastCol))
End With
... ...
(open wbDestination)
Set rgDest = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
rgDest.Resize(rgSource.Rows.Count, rgSource.Columns.Count).Value = rgSource.Value
Range("A:H").Sort Key1:=[D2], Order1:=xlDescending, Header:=xlYes
Thanks.
---------------
The Issue
---------------
- Source workbook, wbSource, has worksheet wsSource
- Destination workbook, wbDestination has worksheet wsDestination.
- Macro takes new data from wsSource and puts it into wsDestination, whereupon all rows are sorted by date in descending order.
- The code below works but the sorting in wsDestination takes time (there's a lot of data).
The Question
---------------
- How can I insert row count from wsSource into wsDestination row 2 onwards?
- Hoping that by adding blank rows in wsDestination will
- allow me to continue using the method where values in destination range = values in source range.
- eliminate need to sort dates in wsDestionation, and
- reduce time taken for macro to run
- Number of rows from wsSource varies.
- Hoping that by adding blank rows in wsDestination will
Partial VBA
---------------
With wsSource
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastCol = .Cells(Columns.Count).End(xlToLeft).Column
Set rgSource = .Range(.Cells(2, 1), .Cells(LastRow, LastCol))
End With
... ...
(open wbDestination)
Set rgDest = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
rgDest.Resize(rgSource.Rows.Count, rgSource.Columns.Count).Value = rgSource.Value
Range("A:H").Sort Key1:=[D2], Order1:=xlDescending, Header:=xlYes
Thanks.