Here you go:
Private Sub cmdCopyToSummarySheets_Click()
Dim intFirstDataRow As Integer, intLastCol As Integer
Dim lngLastDataRow As Integer
Dim strMainSheet As String, strWaitSheet As String, strLeftSheet As String, strActiveSheet As String, strExpelledSheet As String
Dim i As Long, j As Long, k As Long
Dim wsh As Worksheet
Const strID_Col = "A"
Const strStatus_Col = "F"
strMainSheet = Me.Name
strWaitSheet = Sheet2.Name
strActiveSheet = Sheet3.Name
strExpelledSheet = Sheet4.Name
strLeftSheet = Sheet5.Name
intFirstDataRow = 2
intLastCol = Me.Range("A1").End(xlToRight).Column
lngLastDataRow = Me.Range(strStatus_Col & 1).End(xlDown).Row
If lngLastDataRow = Me.Cells.Rows.Count Then
lngLastDataRow = 2
Else
'first clear out all previously copied data in the other sheets:
For Each wsh In Worksheets
If wsh.Name <> Me.Name Then
wsh.Range("A" & intFirstDataRow & ":A" & wsh.Range("A1").End(xlDown).Row).EntireRow.Delete shift:=xlUp
End If
Next wsh
'now run down the status list & copy to the relevent sheet:
For i = intFirstDataRow To lngLastDataRow
Select Case UCase(Me.Range(strStatus_Col & i).Text)
Case "ACTIVE"
Me.Range(strStatus_Col & i).EntireRow.Copy Destination:= _
Worksheets(strActiveSheet).Rows(Worksheets(strActiveSheet).Cells(Cells.Rows.Count, 1).End(xlUp).Row + 1)
Case "WAITING"
Me.Range(strStatus_Col & i).EntireRow.Copy Destination:= _
Worksheets(strWaitSheet).Rows(Worksheets(strWaitSheet).Cells(Cells.Rows.Count, 1).End(xlUp).Row + 1)
Case "LEFT"
Me.Range(strStatus_Col & i).EntireRow.Copy Destination:= _
Worksheets(strLeftSheet).Rows(Worksheets(strLeftSheet).Cells(Cells.Rows.Count, 1).End(xlUp).Row + 1)
Case "EXPELLED"
Me.Range(strStatus_Col & i).EntireRow.Copy Destination:= _
Worksheets(strExpelledSheet).Rows(Worksheets(strExpelledSheet).Cells(Cells.Rows.Count, 1).End(xlUp).Row + 1)
Case Else
Exit For
End Select
Next i
End If
MsgBox ("Update Complete - " & i - intFirstDataRow + 1 & " records processed.")
End Sub
Code is also in the attached workbook (Excel 2003) and is linked to the button in the main sheet. Hope that helps.
Bookmarks