If [from]-[to] display data

Thorian89

New Member
Joined
Jan 4, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi!

I am trying to make a form for work which uses age and weight to do autocalculations and display certain information based on that information. At the moment I am using a DATEDIF-function to display the age in years, months and days. I have made it so that if the age is less than 1, it displays months etc.

I have a dataset that I want to display dependant on age.
If the age is less than zero, I want it to display according to weight instead of age (prematurity). If the age is 0-4 weeks, I want to display something else, 4weeks to 6 months something else, and etc.
Ex.
Age is 1 month and 20 days. Then I want to display f.ex. 3,5.

I have tried making different =IF(DATEDIF) functions but alas, I can't seem to find a smooth and effective way to do this.

Any help with this issue is greatly appreciated!
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,514
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!

In these cases, it is often best if we can see your data and what you would like your expected output to look like. Please post an example and the formulas you are trying.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 

Thorian89

New Member
Joined
Jan 4, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Thank you for the welcoming!

This is my current project

Barneanestesi.xlsm
ABCDEFG
2
3Fødselsdato10.11.20
4Vekt (kg)
5Høyde (cm)
6
7Alder1 måneder, 26 dager
8
9Lengde3,5
10
11
12
13
14
15
16Trying to make it from <=6 months to 12months.
17If age is below 0 I want it to use the weight instead of age to display f.ex. 2.5
Sheet1
Cell Formulas
RangeFormula
C7C7=IF(DATEDIF(C3, TODAY(),"y")=0,"",DATEDIF(C3, TODAY(),"y")&" år, ")& IF(DATEDIF(C3, TODAY(),"ym")=0,"",DATEDIF(C3, TODAY(),"ym")&" måneder, ")& IF(DATEDIF(C3, TODAY(),"md")=0,"",DATEDIF(C3, TODAY(),"md")&" dager")
C9C9=IF(DATEDIF(C3,TODAY(),"m")<=6,"3,5")
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,514
Office Version
  1. 365
Platform
  1. Windows
Do you mean something like this in cell C9?
Excel Formula:
=IF(DATEDIF(C3,TODAY(),"m")<=12,C4,DATEDIF(C3,TODAY(),"m"))
 

Thorian89

New Member
Joined
Jan 4, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Yes, but is there some way to set a range? Like from 6 months to 12 months, show something.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,514
Office Version
  1. 365
Platform
  1. Windows
Like this?
Rich (BB code):
=IF(AND(DATEDIF(C3,TODAY(),"m")>=6,DATEDIF(C3,TODAY(),"m")<=12),C4,DATEDIF(C3,TODAY(),"m"))
 

Watch MrExcel Video

Forum statistics

Threads
1,127,123
Messages
5,622,870
Members
415,935
Latest member
kes1973

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
Top