Thread: Catch error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Karen53 Karen53 is offline
external usenet poster
 
Posts: 333
Default Catch error

Never mind. I've got it.

If TrafficType = "Blocked2" Then

For iCtr = StartRow To EndRow
Debug.Print "Blocked iCtr " & iCtr
TMRnowLMR = 0

On Error Resume Next
TMRnowLMR = Application.VLookup(Sheets(ShName).Range(StartCol &
iCtr).Value, Sheets(ShName).Range("WebBlockedTMR"), 4, False)
If TMRnowLMR 0 Then
Sheets(ShName).Range(LMRCol & iCtr).Value = TMRnowLMR
Else
Sheets(ShName).Range(LMRCol & iCtr).Value = "NA"
End If
Next
End If



--
Thanks for your help.
Karen53


"Karen53" wrote:

Hi,

I'm trying to catch if the value is not there but am unsuccessful. What
have I missed. The IsError does not catch the error and so it errors on the
TMRnowLMR line when it does not match.

Set rngMatch = Sheets(ShName).Range(StartCol & StartRow & ":" & _

StartCol & EndRow)

For iCtr = StartRow To EndRow
Debug.Print "Blocked iCtr " & iCtr

If (IsError(Application.Match(Sheets(ShName).Range(St artCol &
iCtr), _

rngMatch, 0))) Then
Sheets(ShName).Range(LMRCol & iCtr).Value = "NA"
GoTo Continue1
End If

TMRnowLMR = Application.VLookup(Sheets(ShName).Range(StartCol & _
iCtr).Value, Sheets(ShName).Range("WebBlockedTMR"),
4, False)
Sheets(ShName).Range(LMRCol & iCtr).Value = TMRnowLMR
Continue1:
Next

--
Thanks for your help.
Karen53