+ Reply to Thread
Results 1 to 3 of 3

vba code to find row base on some conditions without using a loop or filter

  1. #1
    Registered User
    Join Date
    08-16-2011
    Location
    Tehran,Iran
    MS-Off Ver
    Excel 2007
    Posts
    25

    vba code to find row base on some conditions without using a loop or filter

    Hi again,

    i have a range of data in sheet1 like below:

    Code Year City status
    1 2010 A 1
    2 2011 B 2
    3 2015 A 1
    4 2013 C 2
    5 2009 B 1
    6 2010 A 2
    7 2001 C 1

    I want to find number of the row with this conditions:

    year is between 2011 T0 2014
    city is C
    Status is 2

    I know how to find the row using For Loop or filtering range
    But is there another way, like using match and index or something like that?
    I want to do this in vba
    what is the fastest way?

    thankyou for your help

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: vba code to find row base on some conditions without using a loop or filter

    what do you want to do once you find the row... also what if there is more than one match?



    You could make a column next to the table something like this:

    =AND(C3="C",AND(B3<=2014,B3>=2011),D3=2)

    That would give you column of "true" and "false" values - true meet the three conditions
    Last edited by GeneralDisarray; 07-01-2015 at 09:48 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: vba code to find row base on some conditions without using a loop or filter

    use a helper column
    in d2 use the formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then in vba

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ 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. Find and Display results VBA Code - Loop to find all Matches
    By i2rule in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2014, 03:14 PM
  2. [SOLVED] Base on material code - find out latest P.O. date per project
    By ExcelUser2707 in forum Excel General
    Replies: 4
    Last Post: 07-10-2014, 04:47 AM
  3. VBA code to loop through 3 columns, chk for 2 conditions and email txt from the cells
    By philipcph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 01:14 AM
  4. [SOLVED] Find the code that similar with data base
    By yukioh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2013, 07:24 AM
  5. Autofilter code, if cell Sh1 = text, then use filter on table Sh2 two conditions.
    By Justin25150 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2012, 12:52 AM

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