+ Reply to Thread
Results 1 to 4 of 4

Selecting a number of rows based on the content

  1. #1
    Forum Contributor
    Join Date
    03-14-2005
    Posts
    164

    Selecting a number of rows based on the content

    Hi there,

    I have managed this before, and subsequently lost the file I was working on.
    Being a total amateur in VBA I'm hoping that someone will be able to nudge me in the right direction!:


    I need to create a range of rows (columns are not required - just entire rows)

    an example logic is:
    In Column A, find "Very Likely Projects" - this is the first row in the range
    In Column A, find "Very Likely Projects Total" - this is the last row in the range.
    Select the range.


    simple, yes - can I remember hw to do it? no!
    any help will be gratefully recieved.

    thanks in advance

  2. #2
    Bob Phillips
    Guest

    Re: Selecting a number of rows based on the content

    Here is some code

    Const sFind As String = "Very Likely Projects"
    Dim rngStart As Range
    Dim rngEnd As Range
    Dim rngAll As Range

    Set rngStart = Columns(1).Find(sFind)
    If Not rngStart Is Nothing Then
    Set rngEnd = Columns(1).Find(sFind & " Total")
    If Not rngEnd Is Nothing Then
    Set rngAll = Range(rngStart, rngEnd).EntireRow
    MsgBox rngAll.Address
    End If
    End If


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "matpj" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi there,
    >
    > I have managed this before, and subsequently lost the file I was
    > working on.
    > Being a total amateur in VBA I'm hoping that someone will be able to
    > nudge me in the right direction!:
    >
    >
    > I need to create a range of rows (columns are not required - just
    > entire rows)
    >
    > an example logic is:
    > In Column A, find "Very Likely Projects" - this is the first row in the
    > range
    > In Column A, find "Very Likely Projects Total" - this is the last row
    > in the range.
    > Select the range.
    >
    >
    > simple, yes - can I remember hw to do it? no!
    > any help will be gratefully recieved.
    >
    > thanks in advance
    >
    >
    > --
    > matpj
    > ------------------------------------------------------------------------
    > matpj's Profile:

    http://www.excelforum.com/member.php...o&userid=21076
    > View this thread: http://www.excelforum.com/showthread...hreadid=487981
    >




  3. #3
    Forum Contributor
    Join Date
    03-14-2005
    Posts
    164
    thanks bob,

    that certainly identifies the range and displays it in a box.
    I need excel to actually select the rows, as I then need to perform a cut and then insert in a seperately identified row

    do you know how to do this?

  4. #4
    Bob Phillips
    Guest

    Re: Selecting a number of rows based on the content

    Change

    MsgBox rngAll.Address

    to

    rngAll.Select

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "matpj" <[email protected]> wrote in
    message news:[email protected]...
    >
    > thanks bob,
    >
    > that certainly identifies the range and displays it in a box.
    > I need excel to actually select the rows, as I then need to perform a
    > cut and then insert in a seperately identified row
    >
    > do you know how to do this?
    >
    >
    > --
    > matpj
    > ------------------------------------------------------------------------
    > matpj's Profile:

    http://www.excelforum.com/member.php...o&userid=21076
    > View this thread: http://www.excelforum.com/showthread...hreadid=487981
    >




+ 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