Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Loop through data and build an array

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Loop through data and build an array

    I have a sheet of data, not in table form, more like a report with blocks of data that repeat themselves as you go down the page. I want to go through the data and extract some of the data and copy it to a different worksheet. I was thinking of using the Find function to locate where each block of data starts (Find "Employee No."). I would then want to get the data offset 0 rows and 2 columns (Employee Name) and offset 5 rows and 4 columns, 5 rows and 5 columns, 5 rows and 6 columns, 5 rows and 7 columns and 6 rows and 7 columns (the payroll data), to build a table that looks like this:

    Joe Greene 3251.23 721.43 218.57 25.12 2286.11
    Deacon Jones 3516.67 801.33 266.82 31.48 2417.04
    So on and so forth

    I understand the best way to do this is to build an array then paste it into my spreadsheet. Obviously, I'm not really sure how I do that. Any help would be greatly appreciated as I have several other tasks I could apply this same routine to.

  2. #2
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop through data and build an array

    Its a safe bet that we will need more information and likely an example of the data, particularly its layout.

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop through data and build an array

    Gladly, but, pardon my lack of knowledge, I don't seem to be able to paste in a screen shot and I don't know how to attach the file or somehow transfer the data on the worksheet into this thread.

  4. #4
    Board Regular
    Join Date
    Apr 2009
    Location
    Northeast PA, USA
    Posts
    17,645
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Loop through data and build an array

    2077delta,

    We can not tell what worksheet(s), cells, rows, columns, your raw data is in.

    And, we can not tell what the results should look like.

    Can you post a screen shot of what your data looks like?

    Section B at this link has instructions on how to post a screen shot: https://www.mrexcel.com/forum/board-...forum-use.html

    You cannot upload files to the site, however there are add-ins available here https://www.mrexcel.com/forum/about-...tachments.html that enable you to include sample data in the post

    Alternately, you could upload a copy of your file to a free site such as www.box.com. or www.dropbox.com.

    Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.

    Include a detailed explanation of what you would like to do referring to specific cells, rows, columns and worksheets.

    If the workbook contains confidential information, you could replace it with generic data.
    Have a great day,
    hiker95

    Windows 10, Excel 2007, on a PC.

  5. #5
    Board Regular
    Join Date
    Apr 2009
    Location
    Northeast PA, USA
    Posts
    17,645
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Loop through data and build an array

    2077delta,

    Try this next link, Reply #2 :

    https://www.mrexcel.com/forum/about-...tachments.html
    Have a great day,
    hiker95

    Windows 10, Excel 2007, on a PC.

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop through data and build an array

    Thank you for all the help.

    Here is a link to the file

    https://www.dropbox.com/s/8gn64w3xay...Data.xlsx?dl=0

  7. #7
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop through data and build an array

    Quote Originally Posted by 2077delta View Post
    Thank you for all the help.

    Here is a link to the file

    https://www.dropbox.com/s/8gn64w3xay...Data.xlsx?dl=0

    I am still uncertain of what you hope the results to be.

    Could you do first employee, John Smith, EmpID 103.

    Show me the output. And explain to me which columns you used to create it.

  8. #8
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,247
    Post Thanks / Like
    Mentioned
    92 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Loop through data and build an array

    Quote Originally Posted by 2077delta View Post
    Thank you for all the help.

    Here is a link to the file

    https://www.dropbox.com/s/8gn64w3xay...Data.xlsx?dl=0
    Okay, two things...

    1) Can you post another sheet showing what you want outputted from that same data you just posted?

    2) Your posted sheet shows rows with values like "1 of 37", "2 of 37", "3 of 37", and so on all in rows by themselves. Are those values physically on your data worksheet or are they some kind of page markers that are not really mixed into your actual data?
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  9. #9
    Board Regular
    Join Date
    Apr 2009
    Location
    Northeast PA, USA
    Posts
    17,645
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Loop through data and build an array

    2077delta,

    Your link to your workbook is not working?

    We would like to see what your raw data workbook/worksheets look like, and, we would like to see what the resulting worksheet, manually formatted by you, should look like.
    Have a great day,
    hiker95

    Windows 10, Excel 2007, on a PC.

  10. #10
    Board Regular
    Join Date
    Feb 2002
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop through data and build an array

    I have added a section to the file that shows what the output should look like and the formulas will show which cells the data is coming from. Here is the link.

    https://www.dropbox.com/s/ahn3gzk1gd...Data.xlsx?dl=0

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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