I want to be able to dynamically add a value from a lookup table depending on whether or not a value exists.
This seems like a question that should be solvable with some kind of 'lookup' command, but I can't figure it out.
I've made this a public worksheet anyone can see: https://docs.google.com/spreadsheets/d/10r7oxMEFU6tpJ32zxSuzk4bEtWyAnb7PGtzDxBy8gq4/edit?usp=sharing
There are four columns of names, but it only needs to work with one (clearly).
Let me be more specific. In the linked Google sheet, cell B31 is key.
Here's the user experience: If you put a value into a cell then that means you (assuming you're Joe) want to visit that location for X days (whatever value you input). But then let's say you put another value in a cell further down the list, so now you want to go from the first location to the second, and spend Y days at this new location. The formula in cell B31 should use the table of hours from the "Distances" tab and add that time to the total time that it's calculating.
In this way you can magically plan your trip. The value at the bottom of the column (B31) will be the day your trip needs to finish on to do all the things you want to do, including the travel time between the locations you chose.
Went on a hike, realized I could use another column.
The answer is now on that public sheet, I created a new column for 'Joe' with the following formula which calculates the rolling new date.
=G2+B3+IF(ISBLANK($B3),0,(INDEX(Distances!$B$2:$AD$30,MATCH(INDIRECT("Trip Planner!A"&(COUNTA(B$2:B3)+1)),Distances!$B$1:$AD$1,0),MATCH(INDIRECT("Trip Planner!A"&COUNTA(B$2:B3)),Distances!$A$2:$A$30,0)))/24)
Basically, the logic goes, take the previous time plus the time spent at this location... THEN (assuming the value at this location exists) use 2-column lookup (that is, an index with two match calls) to dynamically find the distance from the last visited location to this one... and add that distance to the mix.
Related
I looked up values from another sheet with the following formula:
=IFERROR(INDEX('Detail list'!$H$2:$H$1604;SMALL(IF(1=((--(A$1='Detail list'!$J$2:$J$1604))*(--(A$2='Detail list'!$I$2:$I$1604)));ROW('Detail list'!$H$2:$H$1604)-1;"");ROW()-2));"")
This lookup is based on two criteria: Company name and year.
The lookup happens in cell A3 and onwards. It uses the company name in A1 and the year from A2 and then finds a corresponding value in another sheet. There's duplicates involved here since the column that is used for this look up consists only of 001 up til 010. It still is able to return all the values in the correct sequence based on year and company name.
I now want to look up or couple a 'corresponding' value with the value that was just acquired. For example: The value in A3 (005) refers to a specific cell in the other sheet. I want to return a value from that exact row but a different column. I have tried the following:
=IFERROR(#INDEX('Detail list'!$B$2:$B$1604;AGGREGATE(15;6;(ROW('Detail list'!$H$2:$H$19883)-ROW('Detail list'!$H$1))/('Detail list'!$H$2:$H$19883=A3);COUNTIF($A$3:$A3;A3)));"")
This does return a value (namely a client value) but this it is not precise as it takes the first 005 it comes across in the full list (so no longer sorted on year and company!) and reports that. I need it to be from the exact row the previous value is referring to.
I'd be so happy if anyone could help me out with this one. If not, I understand completely,
Kind regards,
VHes
Keeping references consistent and clear across sheets while nesting statements can be tricky. Have you considered pasting the data from 'Detail List' into your current sheet and using something like VLOOKUP or INDEX that way?
Another possible solution would be to throw everything into a pivot table and use the filters to get what you need. Not sure if either of these apply to your task.
I have a sheet that updates from a query, attached example. The query is formatted so that the dates are from latest to oldest. I need to pull data from the rows based on the last entry of a specific item that is made each month. There are multiple entries but I only care about the counts for 'Cross1'. So I need the last entry for each of these every January, then February, and so on. This is updated each month. I was conchatenating the date and the description columns for my VLOOKUP.
Originally, I had no problem using a VLOOKUP that just found the entry based on the last day of the prior month, as there was always an entry on the final day of the month. However, the users have now changed the data so that it may not update all the way through the month due to breaks, meetings, vacations, etc. So now my formulas do not work for those months and they will be random. You can see this in the attachment, which I pulled from halfway through December. You can see that Cross1 disappears after the 20th. It has entries for the 21st but the counts are empty. I need to pull the last entry for each month of Cross1 that has the counts filled in. In this case, 12/20, NOT 12/21.
I then tried alternatives such as the LOOKUP function which seemed to be what I needed. However, the function assumes that the data is sorted in the opposite order of my sheet. So, it works and finds what I need, but in the wrong direction (finds the FIRST entry instead). I have asked, and cannot change the query data. So that option is out.
This formula works if the data is sorted with the last date at the top: =LOOKUP(2,1/(c$2:c5995=D4786),a$2:a5995). However, I need to also have it verify that it is the last entry AND there are counts present. In other words, 12/21 would NOT be the entry I want. I would want 12/20 in this example. Thanks to #ronrosenfeld for helping me flesh out my question.
So I am hoping someone has a suggestion. I can go the VBA route but I was thinking there might be something simpler?
Here's one way using array formulas:
Can I create a variable in excel maybe by using macro or anything more simpler, which stores my value and then uses that going ahead in formula,
My main problem is, I am trying to make a formula for calculating Compound Interest monthly, so for Example: I invest Rs.2,00,000 # 10% p.a interest rate.
In normal method I have to do:- 200000*(10%/12) which will give 1666.67, Now i will add (200000+1666.67)*(10%/12) which will give one value and so on.
So i want to create something that can store the Principle amount and Interest each months.
Also i cannot use compounding formula since, lets say in first month i invested only for last 5 days of the month, then interest for first month will be calculated only for 5 months, and then computation of balance month will proceed.
Thanks in Advance. Do let me know if you want any more clarity.
By far the simplest way of storing a static value in Excel, without using any VBA at all, is just to store that value in a single cell. That cell may then be referenced in any formula.
For example if you stored a static value in cell A1, you would reference that value in formulæ as $A$1.
If you don't want the static value on the same spreadsheet on which you're working, then you can create a new sheet named "Static" (or whatever you like) - then reference the cell as Static!$A$1. The sheet may then be hidden if you like.
You speak about adding principal amounts and compound interest. The easiest way to do this would be in a simple table, where the first row contains the initial calculation (including a reference to the static value as above); then subsequent rows reference the row above by means of formulæ. Therefore values would be added and multiplied according to a running total from the row above.
From your question, the specifics are not clear - so if you need more help than this, you'll have to give an example of what actual output you want - including several example rows.
You can also create/use a Named Range in your formula. To create a Named Range:
Formulas > Name Manager > New (Or type name in Name Box as seen in below photo)
This will create a locked reference to a cell (or block of cells for other scenarios) that can be referenced in a formula by name. Make sure this cell has the value you want to reference of course.
For instance, if you name your range Principal, you can refer to the range (value) in a formula as such:
= 2,000 * Principal
This is essentially the same solution as mentioned above, but it may be more intuitive to reference a named range (Principal) rather a locked cell such as ($A$1).
Need solutions for the queries posted in the below link,
http://www.mrexcel.com/forum/excel-questions/334740-dynamically-sum-row-values-based-column-headers.html
Having PersonWeek as separate column with sum of weeks should be displayed.
Quest: Dynamically sum row values based on column headers?
It is good form to re-post the question in its entirety on this site; nevertheless:
What you are looking for is relatively straight forward. There are a lot of ways to accomplish this but I suggest that you use combination of the 'Match' function and the the 'Offset' function. The Offset function creates a range based on a given start point, moving up/down / left/right as indicated, with a given height / width. For example:
=Offset(B2,1,2,3,4)
Indicates the range D3:G5. This is the range given by starting at cell B2, moving 1 row down and 2 columns to the right, and going for a total of 3 rows and 4 columns.
So the remaining point is to determine where to start and stop your offset.
First, the first field in your Offset function will be cell A1, as that is the top-left corner of your data table. To find how many rows to move down, you need to find what project you are referring to (I will assume that cell A6 is where you enter the project name that you care about, A7 is where you enter the first week you care about, and A8 is where you enter the last week you care about). To find how many rows to move down from A1, then, use Match:
=Match(A6, A2:A5,0)
To find how many columns to move to the right to find your first week, use Match again:
=Match(A7, B1:G1,0)
Assuming you only want to look at a single project, we know how high we want the range to be (1).
To find how wide we want the range to be, we need to know your ending week, less your starting week:
=(Match(A8,B1:G1,0)-Match(A7, B1:G1,0))
So the whole thing together will be:
=Offset(A1,Match(A6, A2:A5,0),Match(A7, B1:G1,0),1,Match(A8,B1:G1,0)-Match(A7, B1:G1,0))
Now the only thing left is to wrap the newly defined range in a 'sum' function, like so:
=Sum(Offset(A1,Match(A6, A2:A5,0),Match(A7, B1:G1,0),1,Match(A8,B1:G1,0)-Match(A7, B1:G1,0)))
This formula will create an error if someone enters a project name / weekname in a way that isn't found in your table - so in cells A6-A8 you may want to use data validation to only allow those names to be entered - let me know if you would like elaboration on that.
New to VBA, please help. My apologies. I have not done a good job of making myself clear. Let me try one more time.
My sales reps enter every call into a call sheet. They call on 50-60 people a week; some they will see more than once a week, some only a couple of times a year. On this call sheet are 4 columns; date of call, customer, numerical date, and days since last call. This sheet may have hundreds of rows, many are duplicate customers called on a different date.
I have written code that will eliminate duplicates as needed (works fine). New calls are added using NextRow=_ (also works fine). $C$2 is set at TODAY().
Formula in column C is $C10=$A10(Column C is formatted to number). Column D is number of days since last call; $C$2-$C10 etc. Simple and works fine.
Issue is that say I have 50 rows (all different customers) sorted ascending and a new customer is added, key being new. I need the formulas in C and D to drop down one row automatically when the new customer is added. I can drag the formulas down a head of time and everything will work until I sort, then my data is a the bottom of my sort because all rows in column A without a date will produce a 0 in both C and D. My finished product should be a range of different customers (no duplicates); with the customer that has not been called on the longest at the top.
I hope this is a better explanation. Can I write code to ignore the 0's?
I am going to go a little out on a limb here and say maybe your formulas need refactoring...
For instance. If the aim is to calculate the days since the last call was made to a customer, a simple formula such as this would work
=(max(C:C)-Today())
This gets the largest value in column C and subtracts today from it.
If you want to get the value in column D which corresponds to this entry then VLOOKUP() is your friend. you would use it as such:
=VLOOKUP(MAX(C:C),C:D,2,FALSE)
Hope this helps.
Incidentaly, the best way to do your problem in VBA, the simplest way would be to create a Named Range. You can then replace the $C$2-$D11 with the name of the named range. The simplest way to do this would be to say:
Range(Range(C2),Range(C2).End(xlDown)).Name = NAmeOfYourRange
This effectively just gets cell C2, goes to the last non blank cell in the downward direction and names that range NameOfYourRange
Hope this helps :)