Consulting

Results 1 to 3 of 3

Thread: Copy data range to a new workbook

  1. #1
    VBAX Newbie
    Joined
    Jul 2020
    Posts
    2
    Location

    Copy data range to a new workbook

    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

    t1P.jpg

    copy2p.jpg
    Last edited by SamT; 07-28-2020 at 08:18 AM.

  2. #2
    VBAX Newbie
    Joined
    Jul 2020
    Posts
    2
    Location
    Hi
    Can anyone help ???
    Thanks

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •