Sub PEPP_Report()
Dim rng As Range, cell As Range, del As Range, eeid As String, namefull As String, fname As String, lname As String, c, d As Integer
Dim strCellValue As String
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
strCellValue = (cell.Value)
If InStr(strCellValue, "#") = 0 Then
If InStr(strCellValue, "200 ") = 0 Then
If InStr(strCellValue, "204 ") = 0 Then
If InStr(strCellValue, "G38") = 0 Then
If InStr(strCellValue, "H38") = 0 Then
If InStr(strCellValue, "Y38") = 0 Then
If InStr(strCellValue, "X38") = 0 Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
End If
End If
End If
End If
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
Do
Set rng = Columns(1).Find("*205 *")
If rng Is Nothing Then Exit Do
rng.EntireRow.Delete
Loop
Range("A1").EntireRow.Insert
Range("B1").Value = "Employee #"
Range("C1").Value = "Name"
Range("D1").Value = "SIN"
Range("E1").Value = "CURR EE PEPP"
Range("F1").Value = "YTD EE PEPP"
Range("G1").Value = "CURR ER PEPP"
Range("H1").Value = "YTD ER PEPP"
With Sheets("sheet1").Columns(1)
Set c = .Find("#", LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Let d = c.Row
Let eeid = Mid(Cells(d, 1), 15, 4)
Let Cells(d, 2).Value = eeid
Do
Let d = d + 1
'Let namefull = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
'Let Cells(d, 3).Value = namefull
Select Case Left(Cells(d, 1), 3)
Case Is = "200"
Let Cells(c.Row, 3).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
Case Is = "204"
Let Cells(c.Row, 4).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
Case Is = "X38"
Let Cells(c.Row, 5).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
Case Is = "Y38"
Let Cells(c.Row, 6).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
Case Is = "G38"
Let Cells(c.Row, 7).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
Case Is = "H38"
Let Cells(c.Row, 8).Value = Right(Cells(d, 1), Len(Cells(d, 1)) - 4)
End Select
Loop Until Left(Cells(d, 1), 1) = "#" Or Cells(d, 1).Value = ""
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With
Columns("A:A").Select
Selection.Delete
Dim x As Long
With ActiveSheet
For x = .Cells.SpecialCells(xlCellTypeLastCell).Row _
To 1 Step -1
If WorksheetFunction.CountA(.Rows(x)) = 0 Then
ActiveSheet.Rows(x).Delete
End If
Next
End With
End Sub
Thanks to all!
Bookmarks