Hi everyone, I have these lines of codes:
The code is supposed to find two phrase and use those phrases in the Do Until Loop to transfer records if found otherwise I want the code to do nothing.
Thanks in advance.
Code:
FoundValue = MySheet.Cells.Find(What:="Deductions from Net Pay", After:=Cells(1, 1), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Row
On Error Resume Next
FoundValue1 = MySheet.Cells.Find(What:="Additions to Net Pay", After:=Cells(1, 1), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Row
RowNum4 = FoundValue
On Error GoTo Blue
Do Until MySheet.Cells(RowNum4, 2) = "Total Deductions from Net Pay"
RowNum4 = RowNum4 + 1
CellContent = MySheet.Cells(RowNum4, 3)
If CellContent = "401(K) Loan Repay" Then '1
TransferSheet.Cells(NextRow, 45) = MySheet.Cells(RowNum4, ColNum + 4) * -1
Else
End If
If CellContent = "Moneys Owed to Company" Then '2
TransferSheet.Cells(NextRow, 46) = MySheet.Cells(RowNum4, ColNum + 4) * -1
Else
End If
Loop
Blue:
rownum5 = FoundValue1
On Error GoTo Green
Do Until MySheet.Cells(rownum5, 2) = "Total Additions to Net Pay"
rownum5 = rownum5 + 1
CellContent = MySheet.Cells(rownum5, 3)
If CellContent = "Reimburse-Educational Assist" Then '1
TransferSheet.Cells(NextRow, 47) = MySheet.Cells(rownum5, ColNum + 4) * -1
Else
End If
'If CellContent = "Moneys Owed to Company" Then '2
'TransferSheet.Cells(NextRow, 46) = MySheet.Cells(RowNum5, ColNum + 4) * -1
'Else
'End If
Loop
2:
Green:
Thanks in advance.
Last edited by a moderator: