+ Reply to Thread
Results 1 to 6 of 6

Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

  1. #1
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    A previous poster posed a problem outlined below (and demanded a programmatic approach, despite multiple attempts to 'nudge' a formulaic approach).

    I need a VBA based macro to find all matching jobs which are in Sheet1 column A, in Sheet2 column A and return the corresponding value in column B in Sheet2 to Column B, Sheet 1.
    I originally solved his the query (under the disclaimer that an array approach would be more efficient) with a 2x For Each Next; Offset syntax.

    I have since reapproached the issue for my own personal development via array. As it is widely held that the most efficient code touches the worksheet the least amount of times, my question is this.

    How would my code below (which works) be modified to store all instances of TRUE within the
    Please Login or Register  to view this content.
    line within the array and pass those back to the worksheet in one fell swoop.

    Full code:
    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    Friday bump

  3. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    Friday-Bump

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    you could just use another array, dimensioned to match the row count and populate that with the values in the loop, then write back to the sheet at the end.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    Any chance you could show me how that might possibly look?

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance

    AlvaroSiza,

    This is how I would do it. It only uses a single array, and uses the .Find method to look for matches and then loads it into the array. It outputs the array at the end:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ 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