PC Review


Reply
Thread Tools Rate Thread

Application.VLookup Problem...

 
 
=?Utf-8?B?UmF5cG9ydGluZ01vbmtleQ==?=
Guest
Posts: n/a
 
      6th Sep 2007
I am trying to write code that does the equivelant of a worksheet function
like:
=IF(ISERROR(VLOOKUP(A2,DATERANGE,1,FALSE)),TRUE,FALSE)

What I am doing is looking at a date on the current worksheet (named IMPORT)
in cell A2 and checking to see if that data already exists in my repository
by doing a VLOOKUP to a sheet in the same workbook called "RAW_DATA" in the
named range "DATERANGE".

If the data is already there, I want to throw a message box allowing the
user to stop macro execution. Also, this macro may be called from another
maco, so is there a way to halt ALL macros?

If the data is not there, I want to continue through my process uninterrupted.

So far, my macro does everything I want... except for the validation part.
For that, I have:

'Perform the validation
Dim Res As Variant
Res = Application.VLookup(A1, Range("RAW_DATA!DATERANGE"), 1, False)
If IsError(Res) = True Then
MsgBox ("Data Already Exists!")
'Need an escape to abort all macros here...
End If

I appreciate the assistance!

Regards,
Ray
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      6th Sep 2007
Untested:
Dim Res As Variant
Res = WorksheetFunction.VLookup(Range("A1"), Range("RAW_DATA!
DATERANGE"), 1, False)
If IsError(Res) = True Then
MsgBox ("Data Already Exists!")
End
End If
RayportingMonkey wrote:
> I am trying to write code that does the equivelant of a worksheet function
> like:
> =IF(ISERROR(VLOOKUP(A2,DATERANGE,1,FALSE)),TRUE,FALSE)
>
> What I am doing is looking at a date on the current worksheet (named IMPORT)
> in cell A2 and checking to see if that data already exists in my repository
> by doing a VLOOKUP to a sheet in the same workbook called "RAW_DATA" in the
> named range "DATERANGE".
>
> If the data is already there, I want to throw a message box allowing the
> user to stop macro execution. Also, this macro may be called from another
> maco, so is there a way to halt ALL macros?
>
> If the data is not there, I want to continue through my process uninterrupted.
>
> So far, my macro does everything I want... except for the validation part.
> For that, I have:
>
> 'Perform the validation
> Dim Res As Variant
> Res = Application.VLookup(A1, Range("RAW_DATA!DATERANGE"), 1, False)
> If IsError(Res) = True Then
> MsgBox ("Data Already Exists!")
> 'Need an escape to abort all macros here...
> End If
>
> I appreciate the assistance!
>
> Regards,
> Ray


 
Reply With Quote
 
=?Utf-8?B?UmF5cG9ydGluZ01vbmtleQ==?=
Guest
Posts: n/a
 
      6th Sep 2007
Hey JW:

That didn't fix it... However, I did solve it by following your lead and
playing with the RANGE variables. Here's what finally worked:

'Perform the validation
Dim Res As Variant
Res = Application.VLookup(Range("IMPORT!A1"),
Range("RAW_DATA!DATERANGE"), 1, False)
If IsError(Res) = False Then
MsgBox ("Data Already Exists!")
End
End If

Thanks for your assistance!

Later-
Ray

"JW" wrote:

> Untested:
> Dim Res As Variant
> Res = WorksheetFunction.VLookup(Range("A1"), Range("RAW_DATA!
> DATERANGE"), 1, False)
> If IsError(Res) = True Then
> MsgBox ("Data Already Exists!")
> End
> End If
> RayportingMonkey wrote:
> > I am trying to write code that does the equivelant of a worksheet function
> > like:
> > =IF(ISERROR(VLOOKUP(A2,DATERANGE,1,FALSE)),TRUE,FALSE)
> >
> > What I am doing is looking at a date on the current worksheet (named IMPORT)
> > in cell A2 and checking to see if that data already exists in my repository
> > by doing a VLOOKUP to a sheet in the same workbook called "RAW_DATA" in the
> > named range "DATERANGE".
> >
> > If the data is already there, I want to throw a message box allowing the
> > user to stop macro execution. Also, this macro may be called from another
> > maco, so is there a way to halt ALL macros?
> >
> > If the data is not there, I want to continue through my process uninterrupted.
> >
> > So far, my macro does everything I want... except for the validation part.
> > For that, I have:
> >
> > 'Perform the validation
> > Dim Res As Variant
> > Res = Application.VLookup(A1, Range("RAW_DATA!DATERANGE"), 1, False)
> > If IsError(Res) = True Then
> > MsgBox ("Data Already Exists!")
> > 'Need an escape to abort all macros here...
> > End If
> >
> > I appreciate the assistance!
> >
> > Regards,
> > Ray

>
>

 
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
Application.VLookup ambushsinger Microsoft Excel Programming 11 7th Oct 2008 09:59 PM
Vlookup problem - unable to get the vlookup property Fred Microsoft Excel Programming 2 22nd Aug 2008 05:23 PM
Application.WorksheetFunction.VLookup (Plz Help) Raj Microsoft Excel Programming 4 4th Jul 2007 01:37 PM
Re: Application.Calculate & VLOOKUP Fredrik Wahlgren Microsoft Excel Programming 2 14th Apr 2005 11:55 AM
Application.vlookup problem David Goodall Microsoft Excel Programming 1 14th Sep 2004 06:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 PM.