+ Reply to Thread
Results 1 to 6 of 6

Search through a column and then collect corresponding values from another column...

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    Göteborg, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    14

    Question Search through a column and then collect corresponding values from another column...

    Hello, I have some major lists to organize, and I need some help with the programming to make the process a bit more effective!

    I'm not very proficient with excel nor VB, and all help would be appreciated. I know no cmds in VB whatsoever, so keep it simple whatsoever!


    What I need to do is to search through a specific column in excel (column A in this case), for values in an fix intervall, say 2110 to 2119.
    When those values are found, I want to collect the corresponding values in the same rows, but in another column, L. (These values do not need to be presented)
    I then want to summerize the selected values and place them in a speciefied cell in a different sheet, say F6.

    So all in I just want to put a sum in a given intervall in single cell.

    Any help is deeply apprecieated!

    //Danpo

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Search through a column and then collect corresponding values from another column

    Please can you post a sample workbook illustrating how your data are laid out, and desired results?

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    Göteborg, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Search through a column and then collect corresponding values from another column

    Sure, it is actually quite simple.

    http://imageshack.us/f/39/namnls2d.jpg/ (Hopefully it is visible enough! (Sorry for the Swedish))

    So what I want to do is to browse through column A (Artkod) within a certain interval of numbers. Then sum everything in column L (Utfall) corresponding to those specific numbers and put them in a cell.

    I do not have the copy of the planned layout here at this moment, but if needed, I can post it in about 12 hours, if needed. The sheet that I will be putting the numbers in may be referred to as "temp".

    But the layout is simple, like the previous one, just easier to comprehend. But it is noteworthy that I want to do the algorithm several times with different intervals and hence placing them in different cells.

    I'm thinking like this:
    +For loop to browse column A (largest number in column A is always 9999)
    +if-syntax to determine if the number in column A is in the intervall
    ---when true, pick out number in corresponding cell in column L and ad to the correct cell in the designated sheet.


    That should be pretty much it.. =)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search through a column and then collect corresponding values from another column

    Hello danpo,

    Welcome to the Forum!

    You don't need VBA to do this. You can use the SUMPRODUCT worksheet formula. Here is an example using the sheets named "Sheet1" and "Sheet2". This will sum the values in column "L" if the value in column "A" is between 2110 and 2119. The rows are from 5 to 1000. You made need to change the last row if you have more data.

    In cell F6 on Sheet2 insert the formula below
    =SUMPRODUCT(('Sheet1'!A5:A1000>=2110)*('Sheet1'!A5:A1000<=2119),('Sheet1'!L5:L1000))
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    Göteborg, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Search through a column and then collect corresponding values from another column

    Hey!

    Thanks for the Welcome! =)

    Ok, I did not know that, thanks! You just made my day! If I could, I'd give you a rose!

  6. #6
    Registered User
    Join Date
    06-07-2011
    Location
    Göteborg, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    14

    Question Re: Search through a column and then collect corresponding values from another column

    Hello again!

    I've been using the formula that I've got from here, it has worked perfectly until I recently discovered that it won't work properly if there is a zero in the A column.

    I've been thinking of using an if-syntax somewhere in the productsum formula, and change the zeros to a one, but I cannot figure out how and where to apply it.

    I don't really know if this will solve the problem as I have not been able to try it myself!

    Thanks for your help! =)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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