Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Finding a value in a list

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    101
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I need to find the first zero value in a sorted (descending) list.
    The FIND function fails because it finds the first zero character, as in 20, 30, etc.
    Thanks in advance for your help.

  2. #2
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    813
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Can you explain first zero value by sample data column please?

    And are you looking for a function? So you would get the cell address etc?

    regards
    Suat

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    101
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I need to position cursor on the first zero value in a list such as the following:
    98
    40
    20
    0
    0

    I would then insert a row at the first zero value and perform other sorts on the records above the zeroes.

  4. #4
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    813
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Call the sub like below:

    Call FindValue(Range("A20:A40"),0)

    Sub FindValue(rng As Range, lookupval)
    For i = 1 To rng.Rows.Count
    If rng(i, rng.Column) = lookupval Then
    rng(i, rng.Column).Activate
    MsgBox "Perform Whatever You Want"
    Exit For
    End If
    Next i
    End Sub

    It will find the first cell includes lookup value (0 for you) and activate the cell.

    regards

    _________________
    Oz ~ TheWordExpert

    [ This Message was edited by: smozgur on 2002-04-06 19:19 ]

  5. #5
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    813
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    hmm, to insert a row above this row:

    Sub FindValue(rng As Range, lookupval)
    For i = 1 To rng.Rows.Count
    If rng(i) = lookupval Then
    Rows(rng(i).Row).Insert
    MsgBox "Perform Whatever You Want"
    Exit For
    End If
    Next i
    End Sub

    to just insert a new cell (not whole row)

    Sub FindValue(rng As Range, lookupval)
    For i = 1 To rng.Rows.Count
    If rng(i) = lookupval Then
    rng(i).Select
    ActiveCell.Insert Shift:=xlShiftDown
    MsgBox "Perform Whatever You Want"
    Exit For
    End If
    Next i
    End Sub

    Suat

  6. #6
    Board Regular
    Join Date
    Mar 2002
    Posts
    101
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks smozgur, your routine works just fine.

  7. #7
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    813
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    you're welcome.
    Suat

  8. #8
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Austin, Texas USA
    Posts
    11,654
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-06 18:19, Josue Barocio wrote:
    I need to find the first zero value in a sorted (descending) list.
    The FIND function fails because it finds the first zero character, as in 20, 30, etc.
    Thanks in advance for your help.
    The FIND [command] doesn't "fail" if you check the "Find entire cells only" box.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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