Results 1 to 6 of 6

An InStr Issue

Threaded View

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    Ronks, PA US
    MS-Off Ver
    Excel 2003
    Posts
    10

    An InStr Issue

    I am trying to find the first and last names of people in a cell. I have a userform to get their first and last names separately. I am trying to run a VBA macro to determine if each cell in a column contains both first and last names, and then put a "Y" in an adjacent column. The Code I have is as follows:
        Dim Last, i As Long
        Last = Cells(Rows.Count, "C").End(xlUp).Row
        MsgBox (Employee & " and " & Employee1)
        For i = Last To 1 Step -1
            If InStr(Cells(i, "C"), Employee) = 1 Then
                If InStr(Cells(i, "C"), Employee1) = 1 Then
                    Cells(i, 6).Select
                    If ActiveCell.Value = "Y" Then
                        Application.ScreenUpdating = True
                        Call Message1
                    ElseIf ActiveCell.Value = "" Then
                        ActiveCell.Value = "Y"
                        Call Message3
                    End If
                End If
            End If
    Next
    With just one InStr statement, it finds the first name just fine, but it isn't the right person, because there is more than one person with that first name. the second InStr won't allow it to find anything. I know I'm missing something simple, and would appreciate any help you can provide.
    Last edited by bobo6429; 05-18-2009 at 04:54 PM.
    "It's all fun and games until someone loses an eye. Then it's just one big game of Find The Eye!" -M. Keefer

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