PDA

View Full Version : Copy data range to a new workbook



rb08
07-25-2020, 12:43 AM
Hi



Requests to copy only entries listed in the table


Currently the range is B4: O5 (light blue color)


If there is additional data (for example B4 "O10


Who knew how to copy the above data another time


Each time he will copy only the cells that contain data.





Then want to copy the data to another workbook called a daily diary to a sheet called copy 2 Sheet11




Thanks in advance
rb08

26922

26923

rb08
07-27-2020, 11:05 PM
Hi
Can anyone help ???
Thanks

SamT
07-28-2020, 08:41 AM
This code goes in the Code page of the sheet with the data you need to copy.
The Daily Diary workbook must be open when you run the code.
Edit the code as indicated in its comments.


Option Explicit

Sub CopyData()
Dim DestBook As Workbook
Dim DestSht As Worksheet
Dim FinalDestination As Range

Set DestBook = Workbooks("daily diary.xls?") '<--Use Full Name with full Extension
Set DestSht = DestBook.Sheets("copy 2 Sheet11") '<-Use Full Name of sheet
Set FinalDestination = DestSht.Cells(Rows.Count, "B").End(xlUp).Offset(1)

Range("B4").CurrentRegion.Offset(1).Copy FinalDestination
End Sub