Results 1 to 10 of 10

"Find" method when two columns in the same row

Threaded View

  1. #1
    Registered User
    Join Date
    02-07-2012
    Location
    IN
    MS-Off Ver
    Excel 2010
    Posts
    14

    "Find" method when two columns in the same row

    Hey all,

    I have a program where the user selects a number in a cell based on a criteria. This number can be under a group (Baseball), and a sub group (Yankees). If a number, 2 (restricted by data validation), is selected for Baseball: Yankees, it puts Baseball in one column and Yankees in the next column to form a list that meets this criteria. If both Baseball and Yankees are in the same row, I don't want it to do anything. I run into trouble in my code if I have a list such as:
    Basketball Yankees
    Baseball Devil Rays
    Basketball Cavaliers...

    If I select the criteria 2 for Baseball Yankees, it does not add it to my list. That is because my code sees Basketball first, so it then searches for Yankees. Since it sees Yankees, it does nothing. I would like my code to say if there "Basketball" exists in column P, look in column Q in the same row where Basketball exists, and if Yankees exists in the column Q, do not move the values to columns P and Q.

    If Target.Address = "$H$9" Then
        Application.EnableEvents = False
        If Target.Value = "2" Then
            Set findit = Columns("P:P").Find(What:="*")
            If findit Is Nothing Then
                Cells(7, "P").Value = Cells(9, "G")
                Cells(7, "Q").Value = Cells(8, "B")
            Else
                Set findit = Columns("P:P").Find(What:="Basketball")
                If findit Is Nothing Then
                    Cells(Rows.Count, "P").End(xlUp).Offset(1, 0).Value = Cells(9, "G")
                    Cells(Rows.Count, "Q").End(xlUp).Offset(1, 0).Value = Cells(8, "B")
                Else
                    Set findit1 = Columns("Q:Q").Find(What:="Yankees")
                    If findit1 Is Nothing Then
                        Cells(Rows.Count, "P").End(xlUp).Offset(1, 0).Value = Cells(9, "G")
                        Cells(Rows.Count, "Q").End(xlUp).Offset(1, 0).Value = Cells(8, "B")
                End If
            End If
    End If
    Is there possibly a way to incorporate that into the .Find(What:= field?

    Thanks ahead of time,

    Lucas
    Last edited by LCS; 03-09-2012 at 10:11 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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