+ Reply to Thread
Results 1 to 2 of 2

Selecting range based on values

  1. #1
    Alan M
    Guest

    Selecting range based on values




    I want to select a range consisting of the rows in column B which contain a
    certain value (5). These will all be adjacent to one another. Then extract
    the corresponding values in column M in only these rows to be used for later
    analysis.

    #How can I extract these values into a single column in another worksheet?

  2. #2
    Tom Ogilvy
    Guest

    Re: Selecting range based on values

    Sub GetCells()
    dim res as Variant, rng1 as range
    dim lastrow as Long, rng as Range
    res = Application.Match(5,Columns(2),0)
    lastrow = res
    do while cells(lastrow,2) = 5
    lastrow = lastrow + 1
    Loop
    set rng = Range(cells(res,2),cells(lastrow - 1,2))
    set rng1 = Intersect(columns(13),rng.EntireRow)

    rng1.select
    End Sub

    rng1 will hold a reference to the cells in column M.

    --
    Regards,
    Tom Ogilvy


    "Alan M" <AlanM@discussions.microsoft.com> wrote in message
    news:530A82BC-D6AC-4EDD-BA73-F27B3329575B@microsoft.com...
    >
    >
    >
    > I want to select a range consisting of the rows in column B which contain

    a
    > certain value (5). These will all be adjacent to one another. Then extract
    > the corresponding values in column M in only these rows to be used for

    later
    > analysis.
    >
    > #How can I extract these values into a single column in another worksheet?




+ 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.6.0 RC 1