Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kay
 
Posts: n/a
Default VLOOKUP with IF statement

I want to automatically produce a list of all events that will occur between
two given dates.

I am using VLOOKUP to search the column which has the date for each event. I
want to return the names of all the events that occur before the user-defined
dates.

My formula looks like this:

=IF('CH Milestones'!GM5<Sheet1!A$2,VLOOKUP('CH Milestones'!GM5,'CH
Milestones'!GL$5:GM$87,2,TRUE),"")

GM is the column with the dates.
GL is the column with the event names.
A2 has a user-defined date entered into it.

(In the above formula I was only looking for dates before A2; ultimately I
want only those between two dates.)

Many thanks...

  #2   Report Post  
John Lyons
 
Posts: n/a
Default

Kay

Try

=IF('CH Milestones'!GM5Sheet1!A$2,"",VLOOKUP('CH Milestones'!GM5,'CH
Milestones'!GL$5:GM$87,2,FALSE))


John


"Kay" wrote:

I want to automatically produce a list of all events that will occur between
two given dates.

I am using VLOOKUP to search the column which has the date for each event. I
want to return the names of all the events that occur before the user-defined
dates.

My formula looks like this:

=IF('CH Milestones'!GM5<Sheet1!A$2,VLOOKUP('CH Milestones'!GM5,'CH
Milestones'!GL$5:GM$87,2,TRUE),"")

GM is the column with the dates.
GL is the column with the event names.
A2 has a user-defined date entered into it.

(In the above formula I was only looking for dates before A2; ultimately I
want only those between two dates.)

Many thanks...

  #3   Report Post  
Max
 
Posts: n/a
Default

Another option to try, using non-array formulas ...

Assume the user will enter the Start and End dates in Sheet1's A2:A3
(Start date in A2, End date in A3. If the query involves only a single
date, then the same date has to be entered in both A2 and A3)

In sheet: CH Milestones
------------------
Use an empty adjacent col, say col GN:

Put in GN5:
=IF(OR(Sheet1!$A$2="",Sheet1!$A$3="",GM5=""),"",IF (AND(GM5=Sheet1!$A$2,GM5<
=Sheet1!$A$3),ROW(),""))

Copy GN5 down to GN87

(Ensure GN1:GN4 are left empty)

Then in a new sheet, say Sheet2
---------
we could put in say, B2:

=IF(ISERROR(SMALL('CH Milestones'!$GN$5:$GN$87,ROWS($A$1:A1))),"",INDEX( 'CH
Milestones'!$GL$5:$GL$87,MATCH(SMALL('CH
Milestones'!$GN$5:$GN$87,ROWS($A$1:A1)),'CH Milestones'!$GN$5:$GN$87,0)))

and copy B2 down to B84
(cover the same range size as that done in GN5:GN87 in "CH Milestones")

B2:B84 will return the desired results for the inputs in Sheet1's A2:A3, all
neatly bunched at the top
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"Kay" wrote in message
...
I want to automatically produce a list of all events that will occur

between
two given dates.

I am using VLOOKUP to search the column which has the date for each event.

I
want to return the names of all the events that occur before the

user-defined
dates.

My formula looks like this:

=IF('CH Milestones'!GM5<Sheet1!A$2,VLOOKUP('CH Milestones'!GM5,'CH
Milestones'!GL$5:GM$87,2,TRUE),"")

GM is the column with the dates.
GL is the column with the event names.
A2 has a user-defined date entered into it.

(In the above formula I was only looking for dates before A2; ultimately I
want only those between two dates.)

Many thanks...



  #4   Report Post  
Max
 
Posts: n/a
Default

Here's a link to a sample file with an implemented construct
http://www.savefile.com/files/7767107
File: VLOOKUPwithIFstatement_Kay_misc.xls

And some clarifications:
(Ensure GN1:GN4 are left empty)


Pl disregard the above refrain. It's not applicable here, sorry, since
we're not using entire col references within the SMALL(...) part in the
extract formulas.

In the sample file provided, the results of the query are now extracted
directly into Sheet1's A5:A87, just below the inputs in A2:A3, instead of
into another Sheet2 as posted earlier. The same extract formula is placed
into the starting cell A5, then copied down to A87. Makes for a better
presentation for user to see the query results ! <g
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


  #5   Report Post  
Max
 
Posts: n/a
Default

John, I'm not sure that we can use VLOOKUP here as:
a. As described in the orig. post, the lookup range (in GM5:GM87) is to the
*right* of the return range (in GL5:GL87)
b. VLOOKUP can return only the 1st match value. There is likely to be more
than 1 match involved, if I've read the post correctly
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


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
vlookup inside an if statement? carlosgdlf Excel Discussion (Misc queries) 3 August 4th 05 02:36 AM
vlookup inside an if statement? carlosgdlf Excel Worksheet Functions 3 August 3rd 05 11:38 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
Vlookup of an if statement return James Excel Worksheet Functions 2 April 6th 05 10:28 PM
If/And statement; VLOOKUP? o1darcie1o Excel Worksheet Functions 5 December 29th 04 05:22 PM


All times are GMT +1. The time now is 03:49 PM.

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"