On Error Problems getting to work

mcnealfbm

New Member
Joined
Jul 12, 2004
Messages
33
I saw in an earlier post someone had suggested using On Error and I'm trying to apply it to my code.

I have a main sub routine (Route_Create) and two subroutines (Loader and Expiration)

In the Route_Create routine, I want to look in a specific column and see if the word Expire exists, if it does I want it to call the subroutine Expiration. If it does not then I want it to look in the same column and see if the words Add, Change or Replace exist, if it does then I want it to call the subroutine Loader.

The On Error seems like it might work but I'm don't understand the logic of it so I'm not coding it correctly. I thought an if/else would work better but I couldn't figure out that code.

The first part of the code starts after I find the specific column I need to search for Expire, Add, Replace or Change.

ActiveCell.Select
cellname = ActiveCell.Address
ColNumber = ActiveCell.Column
Rowstart = ActiveCell.row
Rowend = ActiveSheet.UsedRange.Rows.Count

If ColNumber > 26 Then x = 2 Else x = 1
ColLetter = Mid(cellname, 2, x)

' This is where I need the code to look for the words and decide if it should call a subroutine or not.

On Error Resume Next
Cells.Find(What:="Expire", After:=range(ColLetter & Rowstart, ColLetter & Rowend), SearchDirection:=xlPrevious).Select
On Error GoTo 0
Call Expiration

On Error Resume Next
Cells.Find(What:="Add", After:=range(ColLetter & Rowstart, ColLetter & Rowend), SearchDirection:=xlPrevious).Select
On Error GoTo 0
Call Loader

On Error Resume Next
Cells.Find(What:="Replace", After:=range(ColLetter & Rowstart, ColLetter & Rowend), SearchDirection:=xlPrevious).Select
On Error GoTo 0
Call Loader

Thanks for your help!
Frances
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

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