PC Review


Reply
 
 
Karen53
Guest
Posts: n/a
 
      11th Apr 2008
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(StartCol &
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
 
Reply With Quote
 
 
 
 
Karen53
Guest
Posts: n/a
 
      11th Apr 2008
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(StartCol &
> 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

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      11th Apr 2008
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" <(E-Mail Removed)> wrote in message
news:40A900D6-39BA-4450-881E-(E-Mail Removed)...
> 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(StartCol &
> 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



 
Reply With Quote
 
Karen53
Guest
Posts: n/a
 
      12th Apr 2008
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" <(E-Mail Removed)> wrote in message
> news:40A900D6-39BA-4450-881E-(E-Mail Removed)...
> > 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(StartCol &
> > 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

>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      12th Apr 2008
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" <(E-Mail Removed)> wrote in message
> > news:40A900D6-39BA-4450-881E-(E-Mail Removed)...
> > > 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(StartCol &
> > > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to catch error 401 access denied and redirect to custom error page ? rote Microsoft ASP .NET 4 4th Aug 2008 08:27 PM
try..catch catch the error only running inside of VS.NET Dragos Hilbert Microsoft C# .NET 2 11th Mar 2008 03:35 PM
Catch block is failing to catch exceptions when not run from MSDev CodeSlayer Microsoft C# .NET 2 16th Feb 2006 06:42 PM
on error against try..catch =?Utf-8?B?RGF2aWRlUg==?= Microsoft Dot NET 4 11th Jan 2006 04:40 PM
Try Catch Question How Make it go to specific catch? needin4mation@gmail.com Microsoft C# .NET 3 10th Oct 2005 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.