Excel Formula for 2 words - excel

I need to find specific text (in one column) and calculate it and display the answer in another column.
For instance,
find "allocated"
if the date less than today - display SMS2
Find"non-allocated"
if the date more than 7 days fom current date- display sms3
below is my current formula (its wrong) -
=IF(DM4="allocated",DP4<1,if(DM4="non-allocated, DP4>today()+6, "sms1","sms2")
Can anyone help me on this.

Use this:
=IF(AND(DM4="allocated",BP4<TODAY()),"sms2",IF(AND(DM4="non-allocated",BP4>TODAY()+7),"sms1","No value"))

Related

Get number of days between two dates using alternate day as a variable

I have an excel userform that contains four text boxes: start date, end date, Alternate Day number & result.
A user enters a starting and ending date. For example Start Date: 01/oct/2020 and End Date: 04/jan/2021.
In the Alternate Day number text box, the user enters an alternate day number, say 4. This represents that an action begins on every 4th day.
How could I code it so that VBA can work out the total number of alternate days between the two dates?
You could even do this within Excel without VBA if you want to take that route. You could simply use the formula
= (end_date - start_date)/alternate_day_number
You could of course program the same formula in VBA as well.
Basically your question is not clear to give only one answer.
Let's assume the following 2 dates:
You can get the total number as The Guru answered as
=(end_date - start_date)/alternate_day_number
this might come up with something like 3.5 if you only want full days as total number you need to take the integer
=INT(end_date - start_date)/alternate_day_number)
So for this example above the result is 3 but as you can see in the colored numbers depending wether you consider both start_date and end_date to be in the total number you need to add +1 to the result (to make it all 4 dates).

Convert hebrew day-of-the-month to letter(s) in Excel

If I display a date in cell A1 using the cell format [$-8040D] d to show the day of the jewish month, I get a number (from 1 to 30) instead of -the way it is normally displayed- a hebrew letter.
So I want to use
=CHOOSE(A1,"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
But even though I see a number 1-30 displayed in A1, what's really there is a date serial code (something like "44181").
I have tried N(), and VALUE().
What's the correct way to do it?
Thanks!
Excels stores dates numbers as per the Gregorian calendar with 1 = 1 Jan 1900 (and 1900 erroneously being deemed a leap year for competitive reasons).
So first you need to convert the date to the Jewish date (I'm assuming the Jewish Lunar calendar); extract the day of the month(with the TEXT function), and then convert that value to its Hebrew letter equivalent.
eg:
=CHOOSE(TEXT(A1,"[$-he-IL,8]dd"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
or:
=CHOOSE(TEXT(A1,"[$-8040D]d"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
So for today which is
the formula would return
The "correct" way to do it is to realize there is no problem here, no problem at all.
Yes, Excel uses a serial number dating system. However, it completely knows how to interpret it too. So you will have a serial number as the "real" content of A1, but can extract from it the day of the month value. You can do this with:
=TEXT(A1,"d")
This gets you a TEXT "6" if it is December 6. Often that fact (that it returns TEXT) can cause trouble. But only when Excel could expect you could mean either and has to guess which. In the case of the above formula it would be reasonable for it to assume you wanted it looked at as text since the function is... TEXT()...
But in this case, using it in the CHOOSE() function it can ONLY be useful if Excel treats it as a value rather than text. So it does. No need to add anything to force Excel to do so.
So you can just replace the A1 portion of your formula with the above TEXT() function. Then Excel will use it properly and select the correct day of the month from the list.
And that's all you need.

Converting date from general type to date, 9/29/1986 0:00:00 to dd/MM/YYYY CSV file

i have hit wall after trying INT, TIMEVALUE and all other date formatting on the dates in CSV file.
I was able to change few dates using INT and then change the date format but few dates (highlighted in yellow) i am not able to convert to date format. Originally it is string, which i tried changing to Number and Date type before applying formulas but still its not getting formatted correctly.
i have tried MID/LEFT etc. to extract part of it but when joining these parts using "" & "" converts to text and converting it to date resulted in long ##### output, did tried excel advance option ticking Use 1904 date system.
Any help in right direction is much appreciated. i have not found any duplicate question similar to my format, closest i found didnt have time stamp so that formula didnt work either.
Take a look at your date format. The first digit is either 1 or 2 characters and you need to take that variation into account. the nice thing is based on your data that the days is always 2 digits. this simplifies things a little.
Lets start with the basics and assume your first string of a date is in A2. Let us start simply by striping out the numbers from the text one segment at at time while being generic about the position and number of character. So in order to pull out the number for the month, use the following formula:
=LEFT(A2,FIND("/",A2)-1)
Find will look for the position of the / character in the string and return its number. in this case it should be 2. This means its a single digit month. So we only need to pull 1 digit. In the general sense 1 less than the position of the /.
The next task will be to pull the digits for the day. We can do that using a similar formula. This time lets use MID instead of left. In order to for MID to work, we need to define the starting point. This time the general case of the start point will be the first character after the first /. The other nice part about this is we know the number of characters to pull will always be 2. As such you can use the following formula to pull the month:
=MID(A2,FIND("/",A2)+1,2)
(note if your day digits were not consistently 2 then you would have to measure the number of characters between the two / characters and replace the 2 in the formula with you calculation)
In order to pull the year the process is basically the same as for the month with some minor tweaks. The resulting formula I am suggesting is:
=MID(A2,FIND("/",A2,4)+1,4)
Now the reason I used 4 as the starting position for the find is to make the formula work for the case where days could be a single digit. It the closest the second / can be to the start.
now that you have all that you need to combine it together to make the date. This is where the DATE formula comes into play. It works in the following format: DATE(Year, Month, Day). So now we simply grab each of the individual formula and build the DATE formula which should wind up looking like the following:
=DATE(MID(A2,FIND("/",A2,4)+1,4),LEFT(A2,FIND("/",A2)-1),MID(A2,FIND("/",A2)+1,2))
if you get a date that is just bunch of number format the cell to display the date in the format of your choosing.

Is it possible to have Excel return a date when counting down to a date from a specific date that is NOT today or now?

Is it possible to have Excel return a date when counting down to a date from a specific date that is NOT today or now?
Ex: End_date is 04/22/14 and data that I have is "2 weeks before", "3 days before", "4 months before", etc. So I want the cells with "3 days before" to display the date (04/19/14)
I've found info on counting down from today:
=DATEVALUE("22-April-2014")-TODAY()&" days remaining"
but this displays the time remaining and I need the TODAY to be replaced with a value that represents "2 weeks before" April 22 AND for the return to be a dat
This may not be possible :/
Further to my comment above, since your post doesn't mention that you will have text like 1 month before or 2 years before, I am going to assume that they are not there. If they are then we will have to slightly tweak the formula.
Let's say your data looks like this (Ignore the cells in red. I am still experimenting with it)
Simply add this formula in Cell B2 and pull it down
=(LEFT(A2,SEARCH(" ",A2,1)))*(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0))
and this in C2 and pull it down
=DATEVALUE("22-April-2014")-B2
Also Add a small table for lookup in column F:J as shown in the image below
Explanation
I am using Left/Search/Mid to extract the numerical part and the text after that which could be Day/week/Days/weeks/fortnight/fortnights/Months/Years/Month/Year and then using a Vlookup to find the equivalent in days.
So if I break this =(LEFT(A2,SEARCH(" ",A2,1)))*(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) up for the first cell, I get
(LEFT(A2,SEARCH(" ",A2,1))) = 3 and
(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) = 7
and hence = 3*7 =21
(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) can be further broken up
TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))) will give you Weeks and once we know that we do a simple lookup.
Challenges
Like I mentioned, if you have months and days then there can be multiple values for them. See the table.
If the text consists days,weeks,months and years then this solution helps.
in cloumn C add formula ==MID(A1,FIND(" ", A1)+1,3) and drag it down.
in column B add formula =IF((C1="day"),($B$1-LEFT(A5,1)),IF(C1="wee",($B$1-(LEFT(A5,1)*7)),IF(C1="mon",EDATE($B$1,-LEFT(A5,1)),IF(C1="yea",EDATE($B$1,(-LEFT(A5,1)*12))))) and drag it down.
If EDATE() function is not available, and returns the #NAME? error means install and load the Analysis ToolPak add-in.
visit HERE to Load Analysis ToolPak for Excel.
Below is the snap shot of solution.

How to work out if someone is older that 19 in Excel

I have a little problem with Excel. I nead to make a function that checks if a person is older that 19.
I checked for a function online but it does not work the way it should.
First I have a date in a unusual format 14 10 2012 , I used =SUBSTITUTE(J2, " ", ".")
to get 14.10.2012
after that I use a formula
=IF(P2<DATE(DAY(NOW()),MONTH(NOW()),YEAR(NOW())),"Older than
19","Too young")
but no mater what I do it does not work correctly. It shows the same resolute if the number is bigger or smaller
why is =DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY())) showing me 3.4.1920 ?
I think that you might have the parameters around the wrong way. If I put:
=DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY()))
into Excel, I also get 3.4.1920.
If, however, I enter:
=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))
I get 14.10.2012 - today's date!
======
Just as a followup, I suspect that you are trying to compare today's date with a date of birth to determine someone's age and whether they are over 19?
Try this:
Enter the formula above into a cell (hidden if you like) - lets call it A1
Have the person's date of birth entered into another cell - lets say A2
Enter the formula =A1-A2 into a third cell (A3). This gives you their age in days.
Another formula - this time =A3/365.25 (that is, their age in days divided by the number of days in a year). Let's say that's A4
It's then a simple IF statement =IF(A4>19,"Over 19","Too young")
Hope that helps :-)
=IF(YEAR(NOW())-RIGHT(J2,4)>55,"starejsi",IF(YEAR(NOW())-RIGHT(J2,4)=55,
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)>0,"older",
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)=0,
IF(DAY(NOW())-LEFT(J2,FIND(" ",J2,1))>=0,"older","younger"),"younger")),"younger"))
finally i have done it. this is the code

Resources