Design Error Trap

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I am trying to figure out how to utilize a error trap for my macro.

The basic idea is as follows:
For Each c In rng
If c.Value = "Week" Then
If c.Offset(0, 2).Value > 0 Then
If c.Offset(0, 2).Value < Range("$A$20").Value Then
c.Offset(0, 3) = "1"
ElseIf sum of the 24 cells above c.offset(0,2)=0
Run this code
ElseIf sum of the 19 cells above c.offset(0,2)=0
Run this code
ElseIf sum of the 14 cells above c.offset(0,2)=0
Run this code
ElseIf sum of the 9 cells above c.offset(0,2)=0
Run this code
Else
Run this code
End If
End If
End If
Next c

I am trying to test for the least likely to most likely scenario. The problem is that the code errors out on the first elseif statement. I am not 25 rows down the sheet when the first condition is met so I get the error.

In a perfect world - I would use something like On error resume next elseif. Of course we all know this is not a perfect world.

Any idea's?

Thanks,

Kurt
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,148,530
Messages
5,747,234
Members
424,070
Latest member
smanni3

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
Top