On error go to label

Santino_X

New Member
Joined
May 1, 2011
Messages
15
Good night i got a troublesome workbook because it got some lines that say #NAME? and its value is =-TRA. In my code, i would like to skip those cells so the code continues to run. My code is this and i have a comment marked on the spot the label should go:

Code:
Sub OrganizacionParrillaind()
Application.Calculation = xlManual
Application.ScreenUpdating = False

Dim SKU(1 To 21) As Long, c1 As Integer, c2 As Integer, c3 As Integer, c4 As Integer
Dim c5 As Integer, c6 As Integer, pedido(1 To 21, 1 To 163) As Integer
SKU(1) = 244616
SKU(2) = 244640
SKU(3) = 244657
SKU(4) = 244665
SKU(5) = 244681
SKU(6) = 950190
SKU(7) = 950541
SKU(8) = 950558
SKU(9) = 950732
SKU(10) = 2394053
SKU(11) = 2974743
SKU(12) = 3113141
SKU(13) = 3141113
SKU(14) = 3141151
SKU(15) = 3141175
SKU(16) = 3141182
SKU(17) = 3276549
SKU(18) = 3276556
SKU(19) = 4546832
SKU(20) = 4546849
SKU(21) = 4546887

Sheets(3).Activate
c3 = 165
For c1 = 1 To 21
For c2 = 1 To 163
pedido(c1, c2) = Cells(c3, 3).Value
c3 = c3 + 1
Next c2
Next c1
DoEvents

For c1 = 1 To 21
For c2 = 1 To 2
Sheets(c2).Activate
For c3 = 1 To 1390
For c4 = 1 To 50

Cells(c3, c4).Activate
If Cells(c3, c4).Value = SKU(c1) Then
c5 = 0
For c6 = 1 To 160
If Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1049" _
Or Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1182" _
Or Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1197" Then
c5 = c5 + 1
End If
Cells(c3 + c5 + c6 + 3, c4 + 1).Value = pedido(c1, c6)
Next c6
End If

[U][B]' I would like my code to skip up to here if i encounter an error[/B][/U]

Next c4
Next c3
Next c2
Next c1
DoEvents

Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub

Everything else is fine cause i tested it under debug.
Could you help me with that label thing?

Thank you very much!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
The IsError() statement will test if the cell has an error or not.

In the example below, cells with error values will be ignored.

Code:
[COLOR="Red"]If Not IsError(Cells(c3, c4)) Then[/COLOR]
    If .Cells(c3, c4).Value = SKU(c1) Then
        c5 = 0
        For c6 = 1 To 160
            If Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1049" _
               Or Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1182" _
               Or Left(Cells(c3 + c5 + c6 + 3, 2).Value, 4) = "1197" Then
                c5 = c5 + 1
            End If
            Cells(c3 + c5 + c6 + 3, c4 + 1).Value = pedido(c1, c6)
        Next c6
    End If
[COLOR="Green"]' I would like my code to skip up to here if i encounter an error[/COLOR]
[COLOR="Red"]End If[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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