+ Reply to Thread
Results 1 to 15 of 15

Finding Values Contained in an Array in a Sheet

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Finding Values Contained in an Array in a Sheet

    Is this even possible? I have a user enter whatever they want to find in Column A of a random worksheet they are working in. I have written code to store this as an array

    Please Login or Register  to view this content.
    The add-in opens the file(s) that the user wants to pull data from. The ElmArr is what the code is to search for; once it's found it pull data from the same row but a different column and stores that in another array. How can this be done?

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Finding Values Contained in an Array in a Sheet

    your question is too vague, attach a sample file with data and desired result.
    You don't need array for finding a value in a column.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    I'm trying to avoid posting my code due to proprietary reasons. I'm also trying to avoid using vlookup and match.

    All I want it to do is take the array I've created, open the specified file, search for those numbers in the array, create a new array with the numbers associated with what it's found:

    user created array to search file = G, J

    file:

    A |B |C
    -----------
    G |5 |2
    G |5 |8
    H |4 |3
    H |4 |9
    I |8 |4
    I |8 |5
    J |9 |1
    J |9 |6


    The code searches for the values specified, in this case G and J. There will be double of the entries because one will have a max and min value associated with it. I need to to find G and take the max value between the two G's in column C. Same thing with value J. So the answer I should get back is 8, 6. Once this is done and stored in another array I'll paste it to another sheet with it's corresponding user created array. Does this explanation clarify things for you?

  4. #4
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    Curious if anyone in the EF land can help me?
    Thanks, Sam

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Finding Values Contained in an Array in a Sheet

    hi Sam, sort of that within one workbook basing on your story above
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    Thank you! I kept hitting a wall by using find within a for loop and then offsetting the cell once it found it...it was going nowhere fast. It works beautifully...if the array is contained in A1. I tried to adapt the code to the column of A and it kept giving me a type mismatch.

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Finding Values Contained in an Array in a Sheet

    sample, please check attachment
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    Considering how much I use xlDown you'd think I'd realize xlUp and rowcount would be a good idea. Brilliant, thank you!

  9. #9
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    I have a quick questions, I think. If I wanted to grab another cell with it. Say everything was pushed to the right 2 columns so what used to be "A" is not "C" and I want the max value as before but I also want what is contained in column "B", do I need to nest a for loop in there or is there an easier way?

    edit: Basically if I had multiple columns of data and I just wanted to pull out 2 columns instead of just one based on the search array that aren't next to each other.

    I've been looking in ReDim Preserve. Would there be a way to do that and then have it cycle through again and add that extra column? Or is that a less efficient way?
    Last edited by sperry2565; 08-30-2013 at 02:44 PM.

  10. #10
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    So I attempted to add an "And" after the then so pull more but I keep getting a Loop Without Do error....

    But if I end just the if statement and add another if statement based off the answer from the first it works perfectly heh

    Please Login or Register  to view this content.
    Last edited by sperry2565; 08-30-2013 at 04:58 PM.

  11. #11
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    So this didn't occur to me until I started really getting into the rest of my userform, but I realized that this just pulls the second entry for the same letter. So no matter which on of the G's or I's or J's etc... are bigger if just pulls the second entry for it. Is there a way to modify this so that it pulls the max value between the two entries?

  12. #12
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    Bump... anyone maybe?

  13. #13
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Finding Values Contained in an Array in a Sheet

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    I kept trying something similiar to that last night....I was just adding the .offset to the other side of value. Thank you!

  15. #15
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Finding Values Contained in an Array in a Sheet

    I'm going to attempt to make this more complicated...what if it contains both positive and negatives values and you need the biggest number regardless of sign?

+ 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. Finding Contained Text within Multi-Faceted Formula
    By Nuggetross in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-26-2013, 04:49 PM
  2. [SOLVED] Finding Values in a 2d Array
    By cheal2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-14-2013, 10:55 AM
  3. Finding values within an array
    By MattShoreson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2006, 10:15 AM
  4. finding consecutive values in array
    By upstate_steve in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-11-2005, 03:37 PM
  5. finding consecutive values in array
    By upstate_steve in forum Excel General
    Replies: 0
    Last Post: 01-11-2005, 01:03 PM

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