+ Reply to Thread
Results 1 to 4 of 4

Thread: look up value in column

  1. #1
    Registered User
    Join Date
    08-13-2008
    Location
    Australia
    Posts
    3

    look up value in column

    I have a spreadsheet of data and I have one column sorted from highest to lowest number. From the top of my spreadsheet I want to search down this column till I get to the first instance of the number 1 or less, and then stop.

    I can't use the value of 1 to search for, as sometimes the first number less than 1 might be 0.02, or 0.01, or .....

    So using VBA, I can select the first cell, Q2, but how do I check the value of this cell =3,and if not, move on to Q3, Q4 etc.

    Thanks,

  2. #2
    Registered User
    Join Date
    08-13-2008
    Location
    London, UK
    Posts
    8
    You need a loop and to use offset to move you down a line.
    Do until Activecell.value <=1
    'Move down a line Activecell.Offset(1,0).Select
    Loop Laura GB
    Last edited by royUK; 08-13-2008 at 08:23 AM.

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639
    lauraGB, please use Code Tags when posting code.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639
    Try

    Option Explicit
    
    Sub findValue()
        Dim cl     As Range
        Dim rng    As Range
    
        Set rng = ActiveSheet.Range(Cells(1, 3), Cells(Rows.Count, 3).End(xlUp))
        For Each cl In rng
            If cl.Value <= 1 Then
                cl.Select
                Exit Sub
            End If
        Next cl
    End Sub
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ 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.2.0