Vlookuping in different column according to time

ylijohe

Board Regular
Joined
Sep 6, 2002
Messages
58
I am making a program to compare stock prices. Unfortunately the free stock price server changes to position of the last prices when the market closes. When the market is open, I should vlookup column 2, but after closing time (8 pm or 20:00), Ishould vlookup column 4.

Any ideas how to solve this?
How to implement time checking to this formula:
VLOOKUP(A9;(VALUES!A$1:D$278);2;FALSE))
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
=if(now()<12:00,vlookup(1),vlookup(2))
You have to change the time to excel friendly time, but I believe the general format of the formula should work.
 
Upvote 0
you could also use something along the lines of:
=VLOOKUP(A9,Values!A$1:D$278,2+((MOD(NOW(),1)>(20/24))*2),0)

good luck
 
Upvote 0
=VLOOKUP(A9,VALUES!A$1:D$278,IF(MOD(NOW(),1<"20:00"+0,2,4),0)
This message was edited by Mark W. on 2002-09-17 14:17
 
Upvote 0
On 2002-09-17 13:59, ylijohe wrote:
I am making a program to compare stock prices. Unfortunately the free stock price server changes to position of the last prices when the market closes. When the market is open, I should vlookup column 2, but after closing time (8 pm or 20:00), Ishould vlookup column 4.

Any ideas how to solve this?
How to implement time checking to this formula:
VLOOKUP(A9;(VALUES!A$1:D$278);2;FALSE))

=VLOOKUP(A9;VALUES!A$1:D$278,IF(C1>0.833333333333333,4,2),0)

where C1 houses the formula: =NOW()

You probably need to expand the condition of IF. The number 0.833333333333333 is the internal value of 20:00.
 
Upvote 0
Yes. At OR after closing time...

How can I compare 0.833333333333333 and NOW(), or how to separate HOUR from NOW()?
 
Upvote 0
Why not use...

=VLOOKUP(A9,VALUES!A$1:D$278,IF(MOD(NOW(),1)<"20:00"+0,2,4),0)
This message was edited by Mark W. on 2002-09-17 15:56
 
Upvote 0
On 2002-09-17 14:40, ylijohe wrote:
Yes. At OR after closing time...

How can I compare 0.833333333333333 and NOW(), or how to separate HOUR from NOW()?

Using my formulation, you could use:

=VLOOKUP(A9,values!A$1:D$278,2+(HOUR(NOW())>=20)*2,0)

This works the same as the first, but incorporates your hour idea, which, to me, seems a bit cleaner than the backing into the time with the mod route.

Several other good options are presented here.
 
Upvote 0
On 2002-09-17 14:45, Mark W. wrote:
Why not use...

=VLOOKUP(A9,VALUES!A$1:D$278,IF(MOD(NOW(),1<"20:00"+0,2,4),0)
This message was edited by Mark W. on 2002-09-17 14:47

ever so small typo:
=VLOOKUP(A9,values!A$1:D$278,IF(MOD(NOW(),1)<"20:00"+0,2,4),0)
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top