+ Reply to Thread
Results 1 to 5 of 5

Nested loop to match cell text for two columns in different sheets

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    62

    Nested loop to match cell text for two columns in different sheets

    Hello,
    I am trying to get this nested loop to work and I keep getting errors.
    Can someone please help me fix my code?

    I have two sheets with column ranges that I'm comparing text to see if it matches:
    Find Stock Symbols
    Stock & Symbol Data

    Please Login or Register  to view this content.
    Thanks for any help!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,410

    Re: Nested loop to match cell text for two columns in different sheets

    I suggest you post a sample workbook.

    I suspect it would be easier to do this with a formula.

    It looks as though it would be an INDEX/MATCH as you want to return a value from the column before the one being searched.

    Untested, but try:

    =IFERROR(INDEX('Stock & Symbol Data'!$A:$A,MATCH('Find Stock Symbols'!$B2, 'Stock & Symbol Data'!$B:$B, FALSE)),0)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Nested loop to match cell text for two columns in different sheets

    Hi,

    I am not very good at this, but I looks like the loop is incorrect.
    "Next y" is before "End IF". Check by replacing "Else" With "End If".
    Please Login or Register  to view this content.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,410

    Re: Nested loop to match cell text for two columns in different sheets

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-19-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Nested loop to match cell text for two columns in different sheets

    You hit the nail on the head! Switching the "Next y" and "End If" and replacing the "Else" did the trick.
    Thanks so much for everyone's feedback.

    Quote Originally Posted by [email protected] View Post
    Hi,

    I am not very good at this, but I looks like the loop is incorrect.
    "Next y" is before "End IF". Check by replacing "Else" With "End If"....


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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