Excel 2003 - ADDRESS() function issues - excel

I finally thought I had found a way to acutally use excel productively but the code that I followed does not appear to work.
I'm thinking that the code is very limited and can't do what I want but I thought I'd ask to confirm - maybe it is my function that is the problem.
I want to calculate the sum of a row of values for the previous month based on how many days we are into this month (i.e. It is the 20th of April so I want to sum the first 20 days of March to compare against.)
=SUM(G4:ADDRESS(ROW(),7+$BR$3,4))
I basically want to SUM(G4:AA4) and have used the address function to return the cell reference AA4 by taking G4 and adding 20 to the column count.
ADDRESS(ROW(),7+$BR$3,4)
This successfully returns AA7 as expected HOWEVER, when I try to use the returning value in the SUM() function it throws an error...
Am I not able to use this reference in my calculation?

Try the OFFSET function instead:
=SUM(OFFSET(G4,0,0,1,$BR$3))
More info here

You can use indirect Attention in German the names are a bit different:
=SUMME(INDIREKT("G4:" & ADRESSE(4;8+19;1;4)))

Related

How to reference one value to various cells, depending on a date?

Please have a look at the picture I attached, it'll make understanding my problem easier because it's hard to describe.
In the first table, I have capacity data for a product. The capacity changes by the date indicated in the column, i.e. from July 2017 the capacity would be 56, from December 2018 78, and from October 2019 99. The reason why I don't write down the capacity for every month is that I want to save columns.
In the second table, I have every month. I want to reference the correct capacity for each month, e.g. it would be 56 for every month until December 2018.
I have been considering an =INDEX function, but it seems to complex for that. Is there a way to reference like this without using VBA? Would the VBA solution be simple? Or am I forced to write a column for every month's capacity in the first table? Thank you!
https://i.imgur.com/mRoBtTo.png
You can simply use several IF statements to compare the month in your column with the months given in your first table, and put the value of the correponding month.
Let's admit your first row is 1 and first column is A, it should give something like:
= IF(D7>=$F$2; $F$3; IF(D7 >= $E$2; $E$3; IF(D7 >= $D$2; $D$3; "")))
I dont see you columns and rows so i hope you will change them correctly on this formula:
=HLOOKUP(C111,$C$106:$P$107,2,TRUE)
C111 is the cell above your red row.
$C$106:$P$107 is the tableof capacities, i know it is bigger then the current one so you see you can add more columns.
2 is the row number from the capacity table.
true is becouse you dont want it to be the exact value it will take the previews in hte order of items
Both previous answers work perfectly, but I would go this way-
You don't actually need an if to find the previous capacity. you can simply use the approximate match (similar to the hlookup answer) in an index formula
=+INDEX($B$4:$E$5,MATCH($B$9,$B$4:$B$5,0),MATCH(C9,$B$4:$E$4,1))
The product $B$9 matches exact (0), but the date C9 is bigger than or equal (1).
$B$4:$E$5 is the source of capacity and
C9:AF9 the date timeline
Final advantage would be that you can have several products to index, not only a single one.
Could you please try the below formula and provide feedback please?
=IF(AND(D8>=D2,D8<E2),"56",IF(AND(D8>=E2,D8<F2),"78",IF(D8>=F2,"99")))

Subtotal average, of data linked to a particular month in Excel 2016

I have a large spreadsheet and I am struggling to get an average, no formula I have used thus far from google or otherwise, has worked.
The average is an average of time, in particular, hours between a start and end time, converted into days.
In column E9:E1833, I have start time as dd/mm/yyy hh:mm
In column J9:J1833, I have the time in days, from start to finish as [h]:mm (some are empty)
I have an auto filter setup to change with job type / area / status etc, and the result needs to change as data is filtered.
The following formula works, but does not recalculate:
{=AVERAGE(IF(MONTH(E9:E1833)=1,(J9:J1833)))}
The following formula works, but gives an incorrect result:
=AVERAGE(IF(MONTH(E1833)=1,SUBTOTAL(101,(J9:J1833))))
I have tried Offset, with similar results, and many of the "off-the-shelf" solutions produces #Div/0, #REF, #Value or fail to allow the entry altogether.
Any help would be much appreciated, preferably not in VBA, as I don't want to be lumbered with this spreadsheet forever. Thanks in advance.
Since you are going to be filtering, and want the result to change as you filter, just use the AGGREGATE function:
=AGGREGATE(1,3,J:J)
EDIT: Animation added in response to question
The values in the Values column can be times, although you may have to format the result of the AGGREGATE function (cell/numberformat) to show the result as [h]:mm
Note: GIF will play twice. To repeat, refresh the page
The following formula seems to work.
{=AVERAGE(IF(SUBTOTAL(9,(OFFSET(J9:J1833,ROW(J9:J1833)-MIN(ROW(J9:J1833)),0,1)))>0,(IF(MONTH(E9:E1833)=3,SUBTOTAL(9,(OFFSET(J9:J1833,ROW(J9:J1833)-MIN(ROW(J9:J1833)),0,1)))))))}
The SUBTOTAL(9,OFFSET part of the function returns an array where filtered numbers are 0, and visible numbers return their values. If you just averaged that array, you would get the wrong number because you would be averaging all those zeros. So the IF statement just creates an array that returns a FALSE for zero, which is not averaged.
An additional caution that gave me a headache as I was playing around, was you are also filtering on MONTH()=1. The issue with that is, blank cells return a January date, which means they will not be filtered by MONTH()=1

Convert date e.g. Jun 05 2016 08:00:00 to dd/mm/yyyy hh:mm:ss

Got input such as in the topic title.
Trying to figure out how to convert this into UK date and time to be used in calculations.
I've looked at some methods on Google such as using text to columns, but I don't think this is what I'm looking for...
Thanks!
Edit: month is always in abbreviated format.
Edit 2: I should mention that I'm in the UK, and it doesn't seem to convert US date automagically.
Edit 3: Data:
Jun 05 2016 08:00:00 to dd/mm/yyyy hh:mm:ss
Assuming that your source date is a string and it is in the cell D10, the first thing you need to do is convert it to an excel date time serial. In the Excel Date Time serial there are a few things to note.
The integer portion of the number represents the number of days since Jan 1 1900 in windows and I think 1904 on mac
The decimal portion of the number represents the time in fraction of a day. 0.5 would represent noon. Valid Excel times for VBA are 00:00 to 23:59:59. 24:00 is not a valid time, though it will work with some excel formulas
So in order to convert your string to an Excel date serial we will need to rip out the components and dump them into the DATE() function. The date function consists of three arguments:
DATE(year,month,day)
Pretty straight forward with the exception that those values need to be numbers. Why dont we start pulling your information going from the largest unit to the smallest unit.
Thankfully your string is of consistent length. You have leading 0 for your single digits so they will occupy the same space as double digits. So this method will work until the year 9999, but I don't think we are too worried about that right now.
In order to pull the year we look at where it is in your string and how long it is. So by simply counting we know it starts in the 8th character position and its 4 characters long. We use this information with the MID() function
=MID(D10,8,4)
In order to pull the month it get a little more complicated since we need to convert it from an abbreviation to a number. There are several ways of doing this. You could go for a long IF statement which would wind up repeating the pull of the month a 11 times. Instead I decided to use the MATCH() function and built an array of month abbreviations inside it. The MATCH() function will return the number/position of what you are searching for in the provided search list. So as long as we enter the months in chronological order, their position will correspond to their numeric values. As such our formula will look like:
MATCH(LEFT(D10,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0)
The LEFT() function was used to pull the month abbreviation from your string. The 0 at the end tell match to look for an exact match. Important to note, this match method is not case sensitive.
Now to get the day we employ the same principals that we did for pulling the year and we wind up with:
=MID(D10,5,2)
We can now substitute each of the formulas for Year Month and Day into the DATE() function and we will get the date portion of the excel date serial. The formula should look like the following:
=DATE(MID(D10,8,4),MATCH(LEFT(D10,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),MID(D10,5,2))
Now you need to tack on your time portion or figure out the decimal portion. In order to do this I would first recommend trying the TIMEVALUE() function. Since time formats tend to be a lot more standard in format than dates, there is a much higher probability that it will work for you. In order to use TIMEVALUE(), the time portion needs to be ripped from the string. This can easily be done with the RIGHT() function as follows:
=RIGHT(D10,8)
That will give you just the time portion which can then be substituted into the TIMEVALUE() function and looks like:
=TIMEVALUE(RIGHT(D10,8))
If the TIMEVALUE() function does not work for you, then you will need to strip out the hour minutes and seconds and dump their results in to the TIME() function. Do this in the same way you pulled the year and the day for the DATE() function. Just update your character counts. TIME() uses three arguments as follows:
TIME(HOUR,MINUTES,SECONDS)
Now that you have figured out your date portion and your time portion all you need to do is add them together to get all the information into one cell. The resulting formula will look like:
=DATE(MID(D10,8,4),MATCH(LEFT(D10,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),MID(D10,5,2))+TIMEVALUE(RIGHT(D10,8))
Where ever you windup placing that formula, remember to change the formatting on the cell to a custom date. Enter the cell custom format as in the image below.
If you have a list of date times to convert in a column, simply copy your formula and formatted cell down as far as you need to go.
Proof of Concept
Formulas used
For more information on the functions used in the formulas above, follow the links below:
MATCH
DATE
TIMEVALUE
RIGHT
MID
LEFT
{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}
The { } are used to build a custom list or static array.
If you don't want to write a macro in VBA, a cell formula would work if the format is as you specified:
I am assuming the data is in cell B3
=MID(B3,5,2) & "/" & IF(LEFT(B3,3)="Jan","01",IF(LEFT(B3,3)="Feb","02",IF(LEFT(B3,3)="Mar","03",IF(LEFT(B3,3)="Apr","04",IF(LEFT(B3,3)="May","05",IF(LEFT(B3,3)="Jun","06",IF(LEFT(B3,3)="Jul","07",IF(LEFT(B3,3)="Aug","08",IF(LEFT(B3,3)="Sep","09",IF(LEFT(B3,3)="Oct","10",IF(LEFT(B3,3)="Nov","11","12"))))))))))) & "/" & RIGHT(B3,13)
The DATEVALUE function expects a comma between the day and year; the REPLACE function can add that in. The TIMEVALUE function should be able to read that time without modification.
=DATEVALUE(REPLACE(LEFT(A1, 11), 7, 0, ","))+TIMEVALUE(RIGHT(A1, 8))
Note that the original in A1 is left-aligned; this indicates a text value. The converted date/time in B1 is right-aligned; this indicates a true date/time value.
Column B was formatted as dd/mm/yyyy hh:mm:ss. As General it would show as 42526.33333.

Excel time difference

I have two time:
9:29:00 AM (B2)
6:16:00 PM (C2)
I want to get the hh:mm (hours and minutes) between those two times. I tried the following function:
=TEXT(B2-C2,"h:mm")
But I get a #VALUE! error.
I formatted the two time cells as TIME format (*h:mm:ss am:pm) and result cell also as TIME format (hh:mm)
Is that the right way round? Try
=C2-B2
You don't need TEXT function
I believe your #VALUE error is due to your order of subtraction, but I can't be sure without knowing which of those times is B2 and which is C2, and I can't quite comment on your question yet, so an answer it is!
Times in excel are stored as doubles which increment by 1 each day; 0.5 is 12 hours etc.
Best thing to do is use =TEXT(B2-C2,"HH:MM")
This will format B2-C2 (a decimal number) as a time interval.
Of course the contents of B2 and C2 must be numeric; see my VALUE function in the comments.
As barry houdini mentioned back in 2013, I also ran into the error of subtracting giving a negative number, and excel just throws an error. No other response on the internet gave me good results. Although my method is longer, it always works with times in hh:mm:ss AM/PM. Just change the text format part of the formula for whatever you have. My data was:
11:15:45 PM 1:41:20 AM
I converted it to military time for ease with
=TEXT(A2, "hh:mm:ss")
Data was now:
23:15:45 01:41:20
I made another column, let's call it C, that just subtracts the second time from the first time,
=B2-A2
I next used an IF statement on this column, so that if the absolute value of the difference was the same as the number (a positive), I'd use
TEXT(B2-A2,"hh:mm:ss")
which just subtracts the later time from the earlier time. But...
If the absolute value of the difference was not the same, e.g. error-ville with a lot of hashes ##########, I use:
TEXT(24-(A10-B10),"hh:mm:ss")
Altogether, we have one more column, which finally spits out the correct hour difference. This column is predicated on columns A, B, and our error-prone difference column C:
=IF(C2=ABS(C2),TEXT(B2-A2,"hh:mm:ss"),TEXT(24-(A2-B2),"hh:mm:ss"))
this is the most ridiculous thing I have ever done. It's been years and such a simple case, never solved by Excel.

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