#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Catch error

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Catch error

It is hard to help with the little info you have supplied.

Are StartCol and StartRow both numeric variables, because that won't work.
What problems are you getting?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Karen53" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Catch error

Hi Bob,

No, one variable is a string for the column and one is Long for the row
number.

The problem is it doesn't catch the error and errors out on the TMRnowLMR =
line instead, because there is no match on that ictr. Those that match
before the error process ok because they match.
--
Thanks for your help.
Karen53


"Bob Phillips" wrote:

It is hard to help with the little info you have supplied.

Are StartCol and StartRow both numeric variables, because that won't work.
What problems are you getting?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Karen53" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Catch error

If you declare TMRnowLMR as a variant, you can drop the "On error" stuff:

Dim TMRnowLMR as variant 'could be an error
...
If TrafficType = "Blocked2" Then
For iCtr = StartRow To EndRow
Debug.Print "Blocked iCtr " & iCtr
TMRnowLMR = Application.VLookup( _
Sheets(ShName).Range(StartCol & iCtr).Value, _
Sheets(ShName).Range("WebBlockedTMR"), 4, False)
if iserror(tmrnowlmr) then
'no match
Sheets(ShName).Range(LMRCol & iCtr).Value = "NA"
else
Sheets(ShName).Range(LMRCol & iCtr).Value = TMRnowLMR
End If
Next
End If

=====
You could check for a number, too:

If isnumeric(TMRnowLMR) Then
Sheets(ShName).Range(LMRCol & iCtr).Value = TMRnowLMR
Else
Sheets(ShName).Range(LMRCol & iCtr).Value = "NA"
End If



Karen53 wrote:

Hi Bob,

No, one variable is a string for the column and one is Long for the row
number.

The problem is it doesn't catch the error and errors out on the TMRnowLMR =
line instead, because there is no match on that ictr. Those that match
before the error process ok because they match.
--
Thanks for your help.
Karen53

"Bob Phillips" wrote:

It is hard to help with the little info you have supplied.

Are StartCol and StartRow both numeric variables, because that won't work.
What problems are you getting?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Karen53" wrote in message
...
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





--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CATCH-22 won't let me save the file Patrick Riley Excel Programming 19 October 12th 09 10:04 PM
catch event Nader Tewelde Excel Programming 2 June 22nd 07 07:59 PM
How to catch Run-time error '91' [email protected] Excel Programming 3 July 25th 06 08:53 PM
Catch Error in macro sa02000[_23_] Excel Programming 4 April 18th 06 04:38 PM
Catch-22 with Error 59 Dan[_28_] Excel Programming 0 November 13th 03 05:11 AM


All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"