+ Reply to Thread
Results 1 to 10 of 10

Copy specific area with filled cells (range) to another worksheet within the same workbook

  1. #1
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Copy specific area with filled cells (range) to another worksheet within the same workbook

    Dear Excel specialists,

    I have a short question, but first allow me to provide some additional context.
    - I have a workbook, with several worksheets.
    - People are required to fill in a fixed table with data. There is only one exception regarding the fixed table, people are allowed to add more rows in the table.

    What I like to achieve is (pseudo code)

    - Look for data in all worksheets (fixed position: A8 - i8 horizontally, vertical is flexible), except the data in the Summary worksheet
    - Preferably --> Copy all cells within that specific range (A8-i8) and stop when the first cell found that has no value (empty). My script looks for the text : "END"
    - Copy all data within that specific area to the Summary sheet
    - Put all collected data "under each other"


    The problem with the current script is: '
    - It copies total rows instead of an area, so it "wipes" all rows clean in the Summary worksheet. So it also cleans my "conditional formatting" planning table (that is/was positioned in J8- Z8 / and further down).

    To summarize it all:
    - I would like to copy an area instead of rows (because of cleaning the rest of my summary sheet).

    Is this easy to achieve in a simple (easy to understand script/small script)?


    Original Script:
    For Each ws In Worksheets
    If ws.Name <> Planning_Summary_Name Then
    lr = ws.Cells.Find("*End*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
    ws.Range("A8:I" & lr).Copy Sheets(Planning_Summary_Name).Range("D" & Rows.Count).End(xlUp).Offset(2, -3)
    End If
    Next ws

    Thank you (in advance) very much for you support!

    Please check the attachment I provided.
    Attached Files Attached Files

  2. #2
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    It is not copying complete rows, it is copying the specific area only. What is wiping your data is the clear statement -
    Please Login or Register  to view this content.
    Try this -

    Please Login or Register  to view this content.
    You can remove "END" from the all the data sheets now. Also, this will not copy headers, just the data without headers. So, you can manually put in the headers in the summary sheet once in row 1.
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this …


    This solution belongs to good enough readers only …

    According to the attachment as it is a VBA demonstration for starters to paste to the Blad5 (Planning_Summary) worksheet module :

    PHP Code: 
    Sub Demo1()
        
    Dim L&, S&
            
    3
        With UsedRange
            
    If .Column 10 Then .Columns(.Column).Resize(, 10 - .Column).Clear
        End With
            Application
    .ScreenUpdating False
        
    For 2 To Worksheets.Count
            With Worksheets
    (S).[A8].CurrentRegion.Rows
                With 
    .Item(+ (3) & ":" & .Count 1)
                     .
    Copy Cells(L1)
                      
    + .Count
                End With
            End With
        Next
            Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 02-18-2022 at 06:39 AM.

  4. #4
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    HI Sourabhg98 and Marc L,

    Both work like a charm. Thank you very much for you quick support/help.
    Highly appreciated!

    Best regards,

    Hans

    PS.
    Reputation added and closing this thread. :-)

  5. #5
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    Quote Originally Posted by sourabhg98 View Post
    It is not copying complete rows, it is copying the specific area only. What is wiping your data is the clear statement -
    Please Login or Register  to view this content.
    Try this -

    Please Login or Register  to view this content.
    You can remove "END" from the all the data sheets now. Also, this will not copy headers, just the data without headers. So, you can manually put in the headers in the summary sheet once in row 1.
    --------------------------------------

    Hi Sourabhg98,

    I have just one additional question of a problem that I just ran into.
    Is it possible to assign the first row of the past action?
    In the summary sheet I like to get the "Paste" action starting at Row number five. Changing the offset did'nt work, because this will effect the paste result because of the loop.

    Attachment 768895

    Thank you (in advance for your answer)

  6. #6
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    How about putting your headers in row 4? Or you want to keep row 4 empty?

  7. #7
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    Hi Sourabhg98,

    I have just one additional question of a problem that I just ran into.
    Is it possible to assign the first row of the past action?
    In the summary sheet I like to get the "Paste" action starting at Row number five (please see attachment).
    Changing the offset did'nt work, because this will effect the paste result because of the loop.

    Attachment 768895

    Thank you (in advance for your answer)

    Attachment 768897Attachment 768897

  8. #8
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    That's the problem for me.
    This image (with items) is just a part of a large sheet with information.
    This is the reason why a row number / position for the past action is important for me

  9. #9
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    02-05-2021
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365 (version 2022, Build 14931.20764)
    Posts
    180

    Re: Copy specific area with filled cells (range) to another worksheet within the same work

    YES!!!! This did the trick! Thank you very much for your support!!!
    Now I can continue with my work. Again thanks!

    Added again in your reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy One Range of Cells in One Worksheet to Next Available Row in Another Workbook
    By Brad1125 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-28-2016, 07:54 PM
  2. To copy printing area of one worksheet to worksheet in a different workbook
    By sneha1889 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 04:04 AM
  3. Replies: 0
    Last Post: 07-24-2014, 09:11 AM
  4. Vba to Copy from Mass Specific Cells Range to a workbook
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2014, 12:15 PM
  5. VBA to copy unique range to specific range area
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2013, 03:53 PM
  6. Non-Sheet Specific Macro to copy range of cells to next worksheet in WB
    By Petrolcb41 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-29-2010, 11:04 AM
  7. Copy range from one workbook to other in specific cells?
    By fcb1900 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2010, 08:38 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1