mole999
Well-known Member
- Joined
- Oct 23, 2004
- Messages
- 10,524
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
I've been trying to figure out something for work, initially to break down the component parts with formulas and then produce a result.
It finally dawned on me i might be better off writing a UDF for simplicity, and then I hit the snag I don't know enough about them to even start a small one (A good reference guide would be useful if you know of one)
The data
I need to look at the day and use that in the function, also the two percentage enteries, and for each cell take the string value, change to time values, so I can return a decimal hours between the highest / lowest (even across midnight)
I started with (which is rubbish)
can someone just fix the first part so that the values are drawn into the output cell, and I have day and percentages available in code to work from
It finally dawned on me i might be better off writing a UDF for simplicity, and then I hit the snag I don't know enough about them to even start a small one (A good reference guide would be useful if you know of one)
The data
Excel Workbook | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
3 | Band > | 4 | 30% | 60% | |||
4 | Mon | Tue | Wed | Thu | |||
5 | 1 | 0630-1830 | 0630-1830 | 0630-1830 | 0630-1830 | ||
6 | 2 | NRD | NRD | NRD | NRD | ||
7 | 3 | 1800-0500 | NRD | NRD | NRD | ||
8 | 4 | NRD | 1800-0500 | 1800-0500 | 1800-0500 | ||
9 | 5 | 0715-1915 | 0715-1915 | 0715-1915 | 0715-1915 | ||
Section 2 |
I need to look at the day and use that in the function, also the two percentage enteries, and for each cell take the string value, change to time values, so I can return a decimal hours between the highest / lowest (even across midnight)
I started with (which is rubbish)
Code:
Public Function Section2(rng As Range)
'Public Function Section2(start_time As String)
'Public Function Section2(DayValue As String, StartTime As String, EndTime As String)
'DayValue =
Dim Starttimetime As Date
Dim Endtimetime As Date
'Dim starttime
Dim endtime
start_time = Left(start_time, 4)
endtime = Right(endtime, 4)
Starttimetime = TimeValue(start_time)
Endtimetime = TimeValue(endtime)
End Function
can someone just fix the first part so that the values are drawn into the output cell, and I have day and percentages available in code to work from