Results 1 to 3 of 3

Searching Multiple Columns on Same Sheet

Threaded View

  1. #1
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562

    Searching Multiple Columns on Same Sheet

    I am in need of some help. I work at a college and I have a workbook where I maintain enrollment data. Within the workbooks I have a sheet for each school year. On each sheet there is data for each term (fall, spring, summer) and an unduplicated count.

    Here is how the data is set up column wise.

    Fall - Columns A-G
    Spring - Columns I-O
    Summer - Columns Q-W
    Unduplicated - Columns Y-AD

    I am needing to take each student in the Unduplicated section and see which terms they attended. If they attended a specific term, I need to grab a piece of data from that term and put it in over in the undulicated area. The only way I could think to do this is with three separate searches. This is probably grossly inefficient and so far it has not worked at all. I have posted below the code I am currently using. Again this code is not workin at all.

    For lRow = 2 To wsMajors.Cells(Rows.Count, 25).End(xlUp).Row Step 1
    
        sSSN = wsMajors.Cells(lRow, 25).Value
        
        'Search in Fall Term
        Set rMajors = wsMajors.Cells.Find(what:=sSSN, After:=wsMajors.Cells(1, 2), LookIn:=xlFormulas, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False)
        
        If Not rMajors Is Nothing Then
            wsMajors.Cells(lRow, 28).Value = wsMajors.Cells(rMajors.Row, 5)
        Else
            wsMajors.Cells(lRow, 28).Value = ""
        End If
        
        Set rMajors = Nothing
        
        'Search in Spring Term
        Set rMajors = wsMajors.Cells.Find(what:=sSSN, After:=wsMajors.Cells(1, 10), LookIn:=xlFormulas, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False)
        
        If Not rMajors Is Nothing Then
            wsMajors.Cells(lRow, 29).Value = wsMajors.Cells(rMajors.Row, 13)
        Else
            wsMajors.Cells(lRow, 28).Value = ""
        End If
        
        Set rMajors = Nothing
        
        'Search in Summer Term
        Set rMajors = wsMajors.Cells.Find(what:=sSSN, After:=wsMajors.Cells(1, 18), LookIn:=xlFormulas, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False)
        
        If Not rMajors Is Nothing Then
            wsMajors.Cells(lRow, 30).Value = wsMajors.Cells(rMajors.Row, 21)
        Else
            wsMajors.Cells(lRow, 28).Value = ""
        End If
        
        Set rMajors = Nothing
    Next lRow
    Any suggestions on how to do this would certianly be appreciated.
    Last edited by boylejob; 03-27-2009 at 09:49 AM.
    Sincerely,
    Jeff

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