On Error Goto Blue Does not work

Hashiru

Active Member
Joined
May 29, 2011
Messages
286
Hi everyone, I have these lines of codes:
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:
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.
 
Last edited by a moderator:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
The recommended way is to check if the value is found like this:
Code:
Dim rgFound as Range
Set rgFound = MySheet.Cells.Find(What:="Deductions from Net Pay", After:=Cells(1, 1), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
If not rgFound Is nothing then 
   FoundValue = rgFound.Row
Else
   Exit Sub
End If
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top