Consulting

Results 1 to 4 of 4

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

  1. #1

    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
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Use a For Each loop with IF.. And statements

    For Each Cel In Range
      If (Cel.Value >= 1 And Cel.Value = 3) And Cel.Offset(0, 1) = "A" And Cel.Offset(0, 2) = "B" Then
    do something
    End If
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Thank you
    There is a lot of data in sheet1 maybe 2000 rows. For loop is a long prosess.
    Do you know a faster way?

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Filter on city and status then loop only thru SpecialCells xlVisible
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •