I need help creating a code that searches for multiple "items", grabs the offset and pastes it in another sheet. My final goal is to track leave used. I started with Sunday, Sunday is the only day that uses special WK codes. The rest of the week uses the same code. I will be pasting the rest of the week days in adjacent columns.
What i am trying the code to do, is if it the column has HW codes, add them and put them in the Leave Audit sheet as a WK day. But if there is any type of leave used for that day add all leave instead. I was able to figure out how to add the WK days but once I started trying to figure out how to implement the Leave I got lost. Maybe if there is multiple leave used for the day put "MUL" as the descriptor.
The Hours for Sunday are stored in Sheet "Pay1" ED2:ED30. The codes are adjecsent to the hours in EA2:EB30 (merged). I put the Handler because the the cells have formulas and i kept getting errors on cells with no values (only formula).
What i am trying the code to do, is if it the column has HW codes, add them and put them in the Leave Audit sheet as a WK day. But if there is any type of leave used for that day add all leave instead. I was able to figure out how to add the WK days but once I started trying to figure out how to implement the Leave I got lost. Maybe if there is multiple leave used for the day put "MUL" as the descriptor.
The Hours for Sunday are stored in Sheet "Pay1" ED2:ED30. The codes are adjecsent to the hours in EA2:EB30 (merged). I put the Handler because the the cells have formulas and i kept getting errors on cells with no values (only formula).
Code:
Sub SundayTest()
Dim wks As Worksheet, ws
Set ws = Sheets("Leave Audit")
Set wks = Sheets("Pay1")
On Error GoTo Handler
Dim rng As Range
Dim row As Range
Dim cell As Range
'Leave Audit
Set rng = wks.Range("ED2:ED30")
For Each row In rng.Rows
For Each cell In row.Cells
If cell.Value > 0 Then
If cell.Offset(0, -3).Value = "61" Then
ws.Range("C4").Value = "AL"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "62" Then
ws.Range("C4").Value = "SL"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "63" Then
ws.Range("C4").Value = "R/AL"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "64" Then
ws.Range("C4").Value = "CT"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "65" Then
ws.Range("C4").Value = "ML"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "67" Then
ws.Range("C4").Value = "COP"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "68" Then
ws.Range("C4").Value = "EML"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "71" Then
ws.Range("C4").Value = "LWOP"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "72" Then
ws.Range("C4").Value = "AWOP"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "73" Then
ws.Range("C4").Value = "SUS"
ws.Range("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "74" Then
ws.Range("C4").Value = "FUR"
ws.Rage("C5").Value = cell.Value
Else
If cell.Offset(0, -3).Value = "05" Then
ws.Range("C4").Value = "WK"
ws.Range("C5").Value = ws.Range("C5").Value + cell.Value
End If
If cell.Offset(0, -3).Value = "04" Then
ws.Range("C4").Value = "WK"
ws.Range("C5").Value = ws.Range("C5").Value + cell.Value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next cell
Next row
Handler:
End Sub