Converting Time Start/Stop Ranges to Presence/Absence

Thomas Scott

New Member
Joined
Nov 7, 2021
Messages
15
Office Version
  1. 2021
Platform
  1. Windows
I have variables (Var) that operate each year and want to convert only those that are take place in 5-year spans into simple yes/no. There would be only six resulting worksheets with each showing results for only that 5-year span. Partially missing data for start, stop,. or both may be present. I have tried If Then concepts but cannot see how to jump (increment) in 2 and 5 year increments without looping that will require a macro. I can do formulas well but writing macros is a much farther stretch. The following is as far as I can figure out. Thanks for any assistance.

Create Timeslices Model.xlsx
ABCDEFGHIJKL
1NameVar1StartVar1StopVar2StartVar2Stop<==Collected data (> 100 Vars)Reduced to 6 worksheets, each 5 year period
2Alpha2010201220102014
3Beta2011201320102012
4Gamma2010201520142019Problem: Test for operation during 5 year interval and record yes/no
5Delta2015201920162021Partially missing data can be present, i.e., missing a start, stop, or both
6Epsilon2016202020142016
7Zeta2007200820122014
8
9NameVar1Var2<==Worksheet A(2010-2014)
10Alpha11
11Beta11
12Gamma11
13Delta10
14Epsilon01
15Zeta00
16
17NameVar1Var2<==Worksheet B(2015-2019)
18Alpha00
19Beta00
20Gamma11
21Delta11
22Epsilon11
23Zeta00
Example
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Here is a formula solution for your given data. Obviously the formulas etc in A9:C15 and A17:C23 can be moved to separate worksheets.

I wasn't sure what answer you wanted if one or other or both years are missing, although I'm guessing perhaps:
- 1 or other missing - test the remaining value?
- Both missing - answer = no.

If you let me know what you want to do we can probably extend this formula.

junk.xlsx
ABCDEFGHI
1NameVar1StartVar1StopVar2StartVar2Stop<==Collected data (> 100 Vars)Reduced to 6 worksheets, each 5 year period
2Alpha2010201220102014
3Beta2011201320102012
4Gamma2010201520142019Problem: Test for operation during 5 year interval and record yes/no
5Delta2015201920162021Partially missing data can be present, i.e., missing a start, stop, or both
6Epsilon2016202020142016
7Zeta2007200820122014
8
9Year FromYear To
10NameVar1Var2<==Worksheet A(2010-2014)20102014
11AlphaYesYes
12BetaYesYes
13GammaYesYes
14DeltaNoNo
15EpsilonNoYes
16ZetaNoYes
17Year FromYear To
18NameVar1Var2<==Worksheet B(2015-2019)20152019
19AlphaNoNo
20BetaNoNo
21GammaYesYes
22DeltaYesYes
23EpsilonYesYes
24ZetaNoNo
Sheet1
Cell Formulas
RangeFormula
B11:B16B11=IF(OR($F$10<B2,C2<$E$10),"No", "Yes")
C11:C16C11=IF(OR($F$10<D2,E2<$E$10),"No", "Yes")
B19:B24B19=IF(OR($F$18<B2,C2<$E$18),"No", "Yes")
C19:C24C19=IF(OR($F$18<D2,E2<$E$18),"No", "Yes")
 
Upvote 0
Ok, but I did not state the problem clearly enough.
1. Var1Start, Var1Stop, etc. in row 2 need to be tested and the results sent to a new Worksheet. I can change what you proposed to add the sheetname but the 2nd problem is more difficult.

2. There are hundreds of VARs, incrementing every 2 columns (start/stop), so the formula must somehow increment 2 more columns and test again and then send those results. I did not see how a single formula could do that without some sort of counter which made me thing of loops which made think macro.

Thanks.
 
Upvote 0
Murray,

I see that I am still not clear enough. The test for each 5 year time period (in this sample) tests for the 5-year range and sends the results for only that time period to the matching worksheet The first new worksheet would be 2010-2014. The second new worksheet would be the 2015-2019 up to six worksheets receiving the yes/no responses.
All the rows would be checked (example used Greek alphabet) to see if the Start and Stop were within the 5-year range and sent to that worksheet but there can be 1-2 hundred rows.

This all seems strange but I am studying variable start/stops, testing for which time range they occurred, then sending the results to the appropriate time range worksheet. I can do this manually by simply look at the start and stop and knowing if it should be coded yes no, but doing it with Excel is not so easy but with up to 80,000 tests it would be no fun. If only there was real artificial intelligence available!

Thanks again.
 
Upvote 0
No need for AI - we have ourselves. :)

Here is an example using formulas that increments 1 column on the result sheet (e.g. 2010-2014) for every two columns on the data sheet (Sheet1 in my case). I've done 4 vars for demonstration but the number is only limited by the number of columns available on the sheet.

Since you only have six sheets to create this would be quick to set up - the 2010-2014 sheet is an example of the first one.

Here are your data:
ThomasScott.xlsx
ABCDEFGHI
1NameVar1StartVar1StopVar2StartVar2StopVar3StartVar3StopVar4StartVar4Stop
2Alpha20102012201020142010201420102014
3Beta20112013201020122010201220102012
4Gamma20102015201420192014201920142019
5Delta20152019201620212016202120162021
6Epsilon20162020201420162014201620142016
7Zeta20072008201220142012201420122014
Sheet1


and here is the output:

ThomasScott.xlsx
ABCDE
1Year From:2010
2Year To:2014
3
4NameVar1Var2Var3Var4
5AlphaYesYesYesYes
6BetaYesYesYesYes
7GammaYesYesYesYes
8DeltaNoNoNoNo
9EpsilonNoYesYesYes
10ZetaNoYesYesYes
2010-2014
Cell Formulas
RangeFormula
B4:E4B4=LEFT(OFFSET(Sheet1!$B$1,0,(COLUMN(Sheet1!B$1)-2)*2),4)
B5:E10B5=IF(OR($B$2<OFFSET(Sheet1!$B2,0,(COLUMN(Sheet1!B2)-2)*2),OFFSET(Sheet1!$B2,0,(COLUMN(Sheet1!B2)-2)*2+1)<$B$1),"No", "Yes")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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