+ Reply to Thread
Results 1 to 4 of 4

Find secound value in column

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Find secound value in column

    I have this code that selects from "CO OW Market" to "GRP Total" in a column

    Sub BDe()
    Dim rng As Range
    Set rng = Range("D2:D" & Cells(Rows.Count, 4).End(xlUp).Row)
    With ActiveSheet
        .Range(rng.Find("CO OW Market"), rng.Find("GRP Total")).Offset(1, 1).Resize(9, 1).Select  'Offset(1, -1).Select
    End With
    End Sub
    Perfect, but in need to do the same thing, but this time select from "CO OW Market" to "GRP Total" in the same column after the first. meaning "CO OW Market" and "GRP Total" come up twice in the same columun.

    example:

    D6 = CO OW Market

    D8 = GRP Total

    D26 = CO OW Market

    D45 = GRP Total


    I need to select from D26 to D45. They will not always be in the same rows is why I need to find it. They will be in that order though

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find secound value in column

    Maybe:

    Sub mattress58()
    Dim x As Range
    Dim y As Range
    Dim z As Range
    Dim w As Long
    w = Range("D" & Rows.Count).End(3).Row
    Set x = Columns(4).Find("CO OW Market", LookIn:=xlValues, lookAt:=xlWhole)
        If Not x Is Nothing Then
            Set y = Range(Cells(x.Row, "D"), Cells(w, "D")).Find("CO OW Market", LookIn:=xlValues, lookAt:=xlWhole)
             If Not y Is Nothing Then
                Set z = Range(Cells(y.Row, "D"), Cells(w, "D")).Find("GRP Total", LookIn:=xlValues, lookAt:=xlWhole)
                  MsgBox "CO OW Market found in Range D" & y.Row
                  MsgBox "GRP Total found in Range D" & z.Row
            End If
        End If
        Set x = Nothing
        Set y = Nothing
        Set z = Nothing
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Find secound value in column

    Thanks , it had a pop up that notified me of the range that it was in. I need it to select from "CO OW Market" to "GRP Total" the secound time they both apear just like

    Sub BDe()
    Dim rng As Range
    Set rng = Range("D2:D" & Cells(Rows.Count, 4).End(xlUp).Row)
    With ActiveSheet
        .Range(rng.Find("CO OW Market"), rng.Find("GRP Total")).Offset(1, 1).Resize(9, 1).Select  'Offset(1, -1).Select
    End With
    End Sub
    did for the first time they appeared.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find secound value in column

    Try:

    Sub mattress58()
    Dim x As Range
    Dim y As Range
    Dim z As Range
    Dim w As Long
    w = Range("D" & Rows.Count).End(3).Row
    Set x = Columns(4).Find("CO OW Market", LookIn:=xlValues, lookAt:=xlWhole)
        If Not x Is Nothing Then
            Set y = Range(Cells(x.Row, "D"), Cells(w, "D")).Find("CO OW Market", LookIn:=xlValues, lookAt:=xlWhole)
             If Not y Is Nothing Then
                Set z = Range(Cells(y.Row, "D"), Cells(w, "D")).Find("GRP Total", LookIn:=xlValues, lookAt:=xlWhole)
                  Range(Cells(y.Row, "D"), Cells(z.Row, "D")).Select
            End If
        End If
        Set x = Nothing
        Set y = Nothing
        Set z = Nothing
    End Sub
    Will there always only be 2 occurances?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2014, 12:01 PM
  2. Replies: 2
    Last Post: 04-26-2013, 01:16 PM
  3. [SOLVED] Error when using FIND Method to find last row when column is blank
    By the duke in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-01-2013, 10:26 PM
  4. Range.Find to find column and place value in next available cell in one line
    By davegugg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2011, 10:41 AM
  5. Macro take 40 secound to run
    By cyee in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-10-2011, 01:01 AM

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