+ Reply to Thread
Results 1 to 5 of 5

Looping through all worksheets, coppying range of cells that varries in starting & ending

  1. #1
    Registered User
    Join Date
    05-17-2018
    Location
    Florida
    MS-Off Ver
    2016
    Posts
    3

    Arrow Looping through all worksheets, coppying range of cells that varries in starting & ending

    Hello!
    I am trying to make a macro that will loop through all sheets of a workbook and copy a range of cells from each sheet and past in a cumulating summary sheet. Specifically my issue has been arising with how to code for finding the starting row number of the range desired to copy each time.

    The data set from each sheet of the workbook that I am trying to add to a summary always starts with "COPY TO ACCESS" in column A and ends with Lastrow/Lastcol (always column S).

    Any assistance would be greatly appreciated!!!

    Thanks!
    ~Jared

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,414

    Re: Looping through all worksheets, coppying range of cells that varries in starting & end

    It would look something like this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-17-2018
    Location
    Florida
    MS-Off Ver
    2016
    Posts
    3

    Re: Looping through all worksheets, coppying range of cells that varries in starting & end

    Thank you soo much!!!! This was extremely helpful and very close to what I need!
    I would like to still copy the cell containing "COPY TO ACCESS" and the remaining cells bellow it in the "A" column for each of the sheets.
    I made a few minor changes to copy the full range of data I am trying to summarize, but the "A" column has the identifiers for the data:

    Sub CopyToSummary()

    Dim lLR As Long, lNR As Long, lFR As Long
    Dim sh As Worksheet, shS As Worksheet
    Set shS = Sheets("Summary")

    For Each sh In ThisWorkbook.Sheets
    If sh.Name <> "Summary" Then
    With sh
    lFR = Application.WorksheetFunction.Match( _
    "COPY TO ACCESS", _
    .Columns(1), _
    0)
    lLR = .Range("A" & .Rows.Count).End(xlUp).Row
    lNR = shS.Range("A" & shS.Rows.Count).End(xlUp).Row + 1
    .Range(.Cells(lFR - 1, 19), .Cells(lLR, 2)).copy _
    shS.Range("A" & lNR)
    End With 'sh
    End If 'sh.Name
    Next 'sh

    End Sub



    Thanks again!!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,414

    Re: Looping through all worksheets, coppying range of cells that varries in starting & end

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  5. #5
    Registered User
    Join Date
    05-17-2018
    Location
    Florida
    MS-Off Ver
    2016
    Posts
    3

    Re: Looping through all worksheets, coppying range of cells that varries in starting & end

    I nearly have it figured out...can't seem to get the starting cell "COPY TO ACCESS" and the cells bellow it to copy to the "Summary" sheet however. Any assistance with that would be greatly appreciated!

    Thanks again!

+ 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. Replies: 6
    Last Post: 08-20-2016, 03:22 AM
  2. starting and ending month to fill same qty inbetween months
    By cpramesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2014, 03:20 AM
  3. Macro for copying - starting and ending based on value in row
    By rexer231 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2013, 10:29 AM
  4. Select dyanmic range with variable starting/ending cells VBA
    By km2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2013, 12:54 PM
  5. [SOLVED] How to find Starting value and Ending Value of the product
    By svenkata in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-27-2012, 02:27 PM
  6. Charts with setting starting and ending point on x (time)
    By yuri in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-24-2008, 08:28 AM
  7. [SOLVED] Starting work period on a Saturday and ending on a friday
    By JLyons in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2005, 10:06 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