I'm reading up on how to use On Error Resume Next
and I'm trying to figure out how long that line will apply to the program. On the Microsoft site, I found this sentence: "An On Error Resume Next statement becomes inactive when another procedure is called." What exactly does this mean? What is considered to be a procedure?
I ask because I'm using the line in my program, but I don't want it to Resume Next
all the runtime errors which occur, just the obvious one on the next line.
Code:
Dim zRange As Range
Call FilterTableFor(fieldNameColumn, Array("baseunitprice", "burden", "MTLBURRATE", "PurPoint", "Vendornum"))
On Error Resume Next
Set zRange = commentsColumnRange.SpecialCells(xlCellTypeVisible)
zRange.Formula = "target"
Call FilterTableFor(fieldNameColumn)
I've also found (and known for a while) that On Error
or GoTo
lines are considered poor coding. Is there a Try-Catch
which I can use for a line like this?
I'm thinking something like this:
Dim zRange As Range
Call FilterTableFor(fieldNameColumn, Array("baseunitprice", "burden", "MTLBURRATE", "PurPoint", "Vendornum"))
Try
Set zRange = commentsColumnRange.SpecialCells(xlCellTypeVisible)
zRange.Formula = "target"
Catch()
Call FilterTableFor(fieldNameColumn)
Where I don't even do anything with it, as I don't feel a need to.
Thanks for your time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…