+ Reply to Thread
Results 1 to 4 of 4

compare related, consecutive rows, looking for a final status

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2010
    Location
    Durham, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    compare related, consecutive rows, looking for a final status

    I am a teacher. I use a tracking program called Montessori Records Express. This program can output student data to an Excel spreadsheet.
    When I plan a lesson for a child, the following row is generated.
    name=student name, lesson=lessonNumber, date, status=planned

    When the student does the associated work but doesn’t get it completely right, I update the status and the following row is generated:
    name=student name, lesson=lessonNumber, date, status=improving

    If the student, however, gets it right the first time, or corrects his errors, I update the status and the following row is generated:
    name=student name, lesson=lessonNumber, date, status=mastered.

    name date lesson status
    John 11-1-2010 1 planned
    John 11-2-2010 1 mastered
    John 11-3-2010 2 planned
    John 11-4-2010 2 improving
    John 11-4-2010 2 mastered
    John 11-4-2010 3 planned
    John 11-3-2010 4 planned
    John 11-4-2010 4 improving

    Parents have access to this report. After a while, a student’s report can have hundreds of rows. What they and I would like to have is a way to find all of the lessons that were planned but not mastered to see what work hasn’t been finished, either never followed-up on or done but with errors. In the above example, lesson 1 and 2 would be filtered out but the rows for lessons 3 and 4 would remain to show that the child received the lesson but had not finished the work without errors yet.
    Thanks for your help. This would really help the parents to support their children’s work.
    Tom

  2. #2
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: compare related, consecutive rows, looking for a final status

    Please come back to me if this goes over your head but this VBA code will do what you need providing the following is true:

    Row 1 is for column headers
    Column A is Name
    Column B is Date
    Column C is Lesson
    Column D is Status

    Sub HideRows()
    'Determine Last Row
    Range("A1").Select
    Selection.End(xlDown).Select
    LastRow = ActiveCell.Row
    
    'Loop through all rows and put lesson number in column E
    'If lesson has been mastered
    Dim cell As Range
    For x = 2 To LastRow
    LessonNo = Cells(x, 3).Value
    If Cells(x, 4).Value = "mastered" Then
    Cells(x, 5).Value = LessonNo
    End If
    Next
    
    'Now loop through rows again and if the lesson number has been
    'entered into column E then hide that row
    For x = 2 To LastRow
    LessonNo = Cells(x, 3).Value
    If Application.WorksheetFunction.CountIf(Range("E:E"), LessonNo) = 1 Then
    ActiveSheet.Rows(x).Hidden = True
    End If
    Next
    
    'Tidy column E so it doesn't show the lessonnumbers previously added by
    'Macro
    Range("E:E").ClearContents
    End Sub
    
    Sub UnhideAllRows()
    Cells.Select
        Selection.EntireRow.Hidden = False
        End Sub

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: compare related, consecutive rows, looking for a final status

    If the data is returned as implied (ie sorted by student, lesson and date) you can use a lightweight key calculation as basis for a filter.

    Assume Name, Date, Lesson & Status are A:D with first data in row 2

    E2:
    =IF(AND(A2=A3,C2=C3),"",D2="mastered")
    copied down
    Now filter Col E based on FALSE - this will show those lessons for which no "mastered" status is recorded (and last status achieved)

  4. #4
    Registered User
    Join Date
    11-11-2010
    Location
    Durham, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: compare related, consecutive rows, looking for a final status

    Thanks. That's a big help. I'll give those a try.

+ 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