+ Reply to Thread
Results 1 to 4 of 4

VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed

  1. #1
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed

    Like many, I have helped others on this site when I can. But sometimes I need help too when the project is over my head. So, I come to the experts for some assistance on this.

    I have been trying to do this for days, but can't get too far on this. While I can do a simple code that can loop through one block of data, I can't write a code that loops through multiple blocks of data, and copy specific cells to another sheet. I've never had to do that before, so I need help, please.

    I have a spreadsheet with multiple blocks of data (by vehicle, and by date). I need to loop through each block of data for each date and find either of two key words, "Base" or "Base2". If neither word is found, then do nothing and continue to the next block of data.

    If either word, "Base" or "Base2" is found in Column G of a block of data, I need the code to capture the starting time in Column A within that block of data, as well as the ending time in column E of that same block of data. In the attached file, I have colored these two cells (Start and End Time) of each instance with red font. These two cells and the cell with the key word will be copied to Columns D, E and H of the Summary sheet along with the part below.

    Also, when the word "Base" or "Base2" is found in Column G of the main sheet, the code should capture the time that is in Column A of that same row. Then continue down Column G looking for the word, "Head Quarters" When "Head Quarters" is found, the code should capture the time that is in Column A and Column E of that same row. These three values of time, and the cells containing the words "Base", "Base2" and "Head Quarters" should be copied to the next available (last) row of the Summary Sheet along with the Start and End time from the paragraph above. On the main sheet of the attached file, I have colored the cell font with green.

    All these non-contiguous cells should be copied to the next available row on the Summary Sheet, by vehicle, into Columns D, E, G, H, I, K and L)

    Could the Vehicle and Driver information also be written to Column A and B the Summary sheet, as well as the date (which is derived from the cell in Column A on the main sheet) written to Column C of the Summary sheet?

    The Summary sheet should be grouped by vehicle and by date for each of the instances the vehicle went to "Base" or "Base2" and then to "Head Quarters"

    Could each vehicle group be separated by two rows please?

    For clarification, I have depicted the desired result I'm seeking on the Summary sheet of the attached file.

    I hope I have clearly provided all the details of my request.

    Any assistance or help is greatly appreciated.
    Thank you!

    Added comment: Column P contains some of what I have done manually just to be able to create the Summary sheet. Column P is not part of the original file.
    Attached Files Attached Files
    Last edited by Jim885; 03-19-2016 at 09:55 PM. Reason: Added comment
    If I helped in any way, please click the star

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed

    AlphaFrog,

    Thank you so much! That is amazing and brilliant. You nailed it perfectly! I wasn't expecting the borders, so that is the icing on the cake!

    Again, thank you so much for your time and effort. I'm overwhelmed and thankful for your generosity and benevolence.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed

    You're welcome. Thanks for the feedback.

+ 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. Loop through data that's ALMOST always in blocks of 9 rows
    By zookeepertx in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2014, 12:43 PM
  2. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  3. Expert needed... Validation On Multiple Sheets
    By timflinn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2014, 11:32 AM
  4. [SOLVED] Loop Formula needed to reference data by initials.
    By Spreadlover in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-20-2013, 05:29 AM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Replies: 6
    Last Post: 02-28-2012, 07:49 AM
  7. check blocks in loop
    By sybmathics in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-03-2006, 11:40 AM

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