Formula for Percentage based on cell reference with times

Sunshine8790

Board Regular
Joined
Jun 1, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Hello all you really smart people :)
I'm hoping this question falls on the simple side, I'm unable to figure it out.

So, in the example table below you'll see I have a formula showing the current time.
Below that I have a chart with specific times and percentages and a green cell in F4.

My question is: What formula can I place in F4 that will automatically grab the referenced percentages based on the current time?
(For example, if the current time is 12:39 PM, the green cell should display 58.3%, but once the current time is 1 PM the green cell should change to 68.9%)


Book1
ABCDEFG
1
2
312:39 PM
4
5
6
77a9.30%
88a21.00%
99a29.90%
1010a37.70%
1111a49.40%
1212p58.30%
131p68.90%
142p79.50%
153p89.10%
164:30p100.00%
17
18
Sheet1
Cell Formulas
RangeFormula
B3B3=NOW()
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
With proper times in B7:B16 you could use
Excel Formula:
=VLOOKUP(MOD(B3,1),B7:C16,2)
I would suggest having an entry in the table for 12AM as well so that you don't get errors before 7AM.
 
Upvote 0
Solution
Are the values in column B actual times, formatted to display in this way? (Custom format ha/p). If they are text values, there would be a lot of work converting these to times within your formula. As long as they are times, then you can use a simple lookup formula: =XLOOKUP(B3,B7:B16,C7:C16,,-1) or =VLOOKUP(B3,B7:C16,2)
 
Upvote 0
With proper times in B7:B16 you could use
Excel Formula:
=VLOOKUP(MOD(B3,1),B7:C16,2)
I would suggest having an entry in the table for 12AM as well so that you don't get errors before 7AM.
Perfect! Thank you so much, and I have updated the entry to include 12 AM.
 
Upvote 0
As long as they are times, then you can use a simple lookup formula:
You would need to use the MOD function with it as I have done in order to separate the date and time returned by NOW() otherwise the lookup is always going to return the last %age in the table.
 
Upvote 0
My mistake: I didn't take on board that this was a NOW() function. I shall read the questions more carefully in future! I was more concerned that the very abbreviated time column was actual times rather than text values.
 
Upvote 0
I was more concerned that the very abbreviated time column was actual times rather than text values.
In case you're not aware, in the mini sheet they are text (if you hover over formatted cells in the mini sheets you can see the underlying values, if nothing shows then they are text), although from the OP's response I would assume that the actual sheet contains proper times.
I shall read the questions more carefully in future!
I've lost count of how many times I've said that and forgotten to do it with the next question :oops:
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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