Entering repeating data in Excel - excel

I am a travel agent and maintain a data base tracking my commission. I am constantly adding new bookings which consist of a hotel name, address and zip code. Many of these hotels I use quite frequently so when i type the name of the hotel in cell A1, I wold like cell A2 to automatically populate with the address, cell A3 to populate with the state and cell A4 to populate with the zip. I could eliminate a lot of data entry. How could I do this.

In another sheet enter the information for all the hotels. I suppose that you could have unique names for your hotels. You can use VLOOKUP() to search that table and populate that information.
If you want the information to appear automatically, just have more rows of formula than you have data on your sheet and use IFERROR() so that if there is no data entered into the first column you do not display an error.
As you can see here, the information is retrieved via VLOOKUP on another sheet and the formula you see is in B2. Normally that cell should display #N/A but since we are using IFERROR() this does not happen and you have a nice output.
And here because I think you might not be familiar with VLOOKUP. VLOOKUP has 4 parameters:
The value to look for;
The range in which 1) the value to look for is and 2) the value to retrieve is;
The number of the column in which the information to retrieve is;
0 if you want an exact match, 1 if you want an approximate match
You just have to remember that VLOOKUP will always use the first column of the supplied range to search for the specified value so you 'key' has to be in the first column.

Create an additional worksheet containing the hotel data and then use something like vlookup from your primary worksheet.

Related

Want a named list with non-continuous cells

I thought this should be a common thing but my search has not returned anything meaningful. I'd prefer an Excel solution, rather than VBA.
I have a proposal sheet with details like number (col D), date etc and a column saying if the proposal got converted (to business).
On the invoice sheet, I have a list of invoices. The requirement is to always refer the proposal number against which this invoice is being raised. For removing human error, the applicable proposal numbers should be available as a drop down. Hence the drop down should only show the proposal numbers against which the invoice can be issued (proposal got converted to business).
This means that non-continuous cells (say, D3, D4, D6, and D10 - where proposal converted is 'yes') from the proposal sheet should be the values available in drop down of data validation in the invoice sheet. How do I achieve this?
Edit:
Adding an image that is representative of the 2 sheets.
My solution involves creating a list using the INDEX MATCH or INDEX SMALL method to pull multiple results from the data that can be used for the dropdown.
I added a couple of extra columns to count the number of times an invoice has been invoiced and then a further Yes/No to make the index formula easier to follow. You'll see that my example only has 2 values to select from as the others have been fully invoiced.
The scary formula in Q1
=IFERROR(INDEX($A$2:$H$1000,SMALL(IF(($H$2:$H$1000="Yes"),ROW($A$2:$H$1000)-1),ROW(1:1)),1),"")
This is an array formula so you must use SHIFTCTRLENTER instead of just ENTER in the formula bar. {} backets will be added if you do it right.
To break it down, INDEX($A$2:$H$1000 is selecting your proposal data and some more rows below (1000). SMALL(IF(($H$2:$H$1000="Yes") is looking at my extra Yes/No column for "Yes". ROW($A$2:$H$1000)-1) is returning the row number minus 1 to account for the fact that our range starts at A2. ROW(1:1) is saying that we want first match in the list and the ),1) returns the vlue in the first column of the range $A$2:$H$1000.
Because ROW(1:1) returns the first result, you will need to autofill down in order to pull more results. As you do this the formula will copy down as 1:1, 2:2, 3:3...ect. I filled down to row 50 to allow for a decent amount of results.
You could set your validation range to Q1:Q50 but then you would have lots of empty space in your dropdown so, have a look at cell R1.
="Q1:Q" & COUNTA(Q1:Q50)-COUNTBLANK(Q1:Q50)
This formula creates a range based on the results in column Q. You can use that value in the data validation range by entering.
=INDIRECT($R$1)
Thus creating the dynamic range that you require.
You don't have to use the extra columns that I added but the formulas are;
=COUNTIF(M2:M1000,A2) to count the number invoiced
=IF(AND(F2="Yes",G2<E2),"Yes","No") to check if it can still be invoiced.
if you do want to use them then I'd recommend formatting your data as a table so that the formulas are copied down automatically on new rows.
Also I'd advise putting the index list on a different sheet so that rows are not deletes etc.

Generate or fill cell data based on another dataset excel

I've a data set that shows;
employee name
date
time work started
time work ended
Now I am trying to have a report like sheet where I can select a certain employee name from a list of employees to view his/her time attended for a particular month.
I tried vlookup but went no where since I need to lookup by two columns plus a row.
Is this possible? without macros or vba.
Thanks
Since name and date are unique identifiers it is possible to use the sumifs function.
For ‘time in’ and ‘Rachel’ this will look as follows:
=Sumifs(column ‘time in’ from data set, column ‘name’ from dataset, “Rachel”, column ‘date’ from data set, “10/01/2017”)
Where Rachel and the date also can be a referenced cell.
=AGGREGATE(15,6,ROW(SHEET1!$A$2:$E$22)/((SHEET2!$B$1=SHEET1!$B$2:$B$22)*(SHEET2!$A4=SHEET1!$C$2:$C$22)),1)
The above formula will grab the row number that matches your criteria. to pull the information you want, you can place the row number inside an INDEX formula to get the following:
=INDEX(SHEET1!$D:$E,AGGREGATE(15,6,ROW(SHEET1!$A$2:$E$22)/((SHEET2!$B$1=SHEET1!$B$2:$B$22)*(SHEET2!$A4=SHEET1!$C$2:$C$22)),1),COLUMN(A1))
You can place the above in your first Time cell and copy right and down. You will see errors if criteria do not exist. ie no person of that name or no date data for that person. to avoid this you can wrap the whole thing in an IFERROR like the below:
=IFERROR(INDEX(SHEET1!$D:$E,AGGREGATE(15,6,ROW(SHEET1!$A$2:$E$22)/((SHEET2!$B$1=SHEET1!$B$2:$B$22)*(SHEET2!$A4=SHEET1!$C$2:$C$22)),1),COLUMN(A1)),"Nothing found")
if you would rather a blank than nothing found display change the "nothing found" to "" or 0 if you want 0 to be displayed.
Note: Aggregate is performing array like calculations in this case. As such you do not want to full column references as it will cause a lot of unnecessary calculations to be performed. Because you have unique entries, SUMIFS option given in another answer is a much better choice.
I think a pivot table will do the job for you.
Place the employee name in the filter, place date and
times in the rows.
Remove subtotals from the Pivot Table
Change Table layout to tabular and Repeat rows
Right click on the Time In and select Ungroup
Then you have the image below.
I have the following layout:
In B11 write this formula and drag down:
=INDEX($B$2:$E$5,MATCH($B$7&$A11,$B$2:$B$5&$C$2:$C$5,0),3)
In C11 write this and drag down:
=INDEX($B$2:$E$5,MATCH($B$7&$A11,$B$2:$B$5&$C$2:$C$5,0),4)
Note that these are Array-Formulas, so you need to enter them with CTRL + SHIFT + ENTER instead of the normal Enter.
You will get a #NV error if the employee hasn't worked on one of the dates A11 and A12. So you could surround the Formula with IFERROR to avoid this.

EXCEL: How to merge 2 sets of customer data

I am sure this question has a really easy answer, but after extensive research I have somehow not found what I was looking for. I am not an excel pro, but do have some experience with it.
Basically I have 2 sets of data that is indexed by customer account number and gives certain values, such as sales, profits, costs etc in the one file and sales rep responsible, amount of times contacted in the other file.
My goal now is to get these two files into one, so that I have the customer ID in the first column and all the data respective to that customer number in the columns next to it on one sheet.
However the customer numbers from the two sheets are not sorted in any way so I cant just copy and paste it and i am dealing with quite a large data set so I cannot just do it manually. additionally there are more customers id's in the first sheet than in the second, since some data is missing for a certain amount of the customers.
How can I basically automatically merge the data belonging to each customer so that it ends up being displayed in one row?
I recommend that you approach the merging of these two lists by creating a 3rd, comprehensive listing, which pulls from your raw data files.
Setting up your new Results Sheet
Assume that one list is in Book1, sheet1, and the other list is in Book2, sheet1. Open up a new excel file. Put the headers along the top. Next, you will create an index which shows all unique customer ID numbers, sorted by number. This will only work if there are no duplicate ID's (except for the ones which refer to the same cusotmer).
Copy the Customer ID column manually from Book1 into the New book. Copy the customer ID's from Book2 manually, underneath the Book1 customers, in the same column in the New book. Highlight the customer ID column. Go to the Data ribbon, then Remove Duplicates. Then rightclick your data and click 'sort'. This will leave you with an ordered customer ID column, and all other fields under the other headings will be blank.
Vlookup Formula
Next, you will use 2 vlookup formulas, similar to what #StaceyBurns recommends below. Vlookup takes a specific unique value, and looks for that value on the leftmost column of a datablock. Then it finds the first time there's a match for that value, and returns a value from a cell on that row, a given number of columns away. So for example:
=VLOOKUP(A1,B1:D5,2,FALSE)
Says: Take the unique value found in A1, look for that value in column B, from row 1:5, and return the 2nd column's result out of the datablock B:D (column C). So if A1 was the same as B3, this formula would provide the result for C3. FALSE means it would try and approximate your value if there's no match.
Assume customer indexes for all files are in column A. Assume also that all other headers are in the same order, let's say from A1:H1. Your formula to use VLOOKUP in the new workbook would be as follows - put this in B2:
=VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,column(),FALSE)
This gives you the matching amount under Sheet1's column B header, where Sheet1!'s customer ID matches the customer ID shown in cell A2 of the New book. However, we need to know whether it was able to properly pick up a value from Book1 - because we know that some data is incomplete. So, let's check if the above result is either a number, or text:
Determining if Results are found in Sheet1
=OR(ISTEXT(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)),ISNUM(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)))
This will return TRUE if the result is either a Number, or Text. So it will return FALSE if either no match is found for that ID number on Book1 Sheet1, or if the result is a blank cell. So now we put that inside of an IF statement - if it returns true, we want the result from Book1. If it returns false, we want to attempt to pull the result from Book2, through the exact same formula. This whole thing will look like this:
Final Formula
=IF(OR(ISTEXT(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)),ISNUM(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE))),VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE),VLOOKUP($A2,[Book2.xlsx]Sheet1!$A:$H,COLUMN(),FALSE))
Now, it will try to find the match from Book1 - if there's no match for the ID, or if the match returns a blank value for that header, then it will try to find a match from Book2. If it finds no match there, it will return #N/A! (which shouldn't happen, because that means you've deleted one of the customer ID's that we pulled directly from Book1 & Book2). It might return a blank cell if that data piece is not in either sheet. This formula can be copied from B2 all the way to the bottom right of your data block in your results sheet.
You can use the VLOOKUP function on the first sheet to bring the data from the second sheet in.
So for example, take an empty column on your first sheet and add the VLOOKUP function which looks like this:
=VLOOKUP(cell to lookup,
set of data on 2nd file,
column index on 2nd file of data you want,
TRUE/FALSE Boolean to ask for either close match or exact match )
If your Customer ID is in column A and your second sheet looks like this:
A1 Customer ID
B2 Sales Rep
C3 Number of Times Contacted
then you would do a look up first for the Sales Rep:
=VLOOKUP(A1,Sheet2!$A$1:$C$15,2,FALSE)
Then double click on the bottom right corner of this cell to populate the formula for all your rows.
Then do the same in a new cell for the Number of Times Contacted:
=VLOOKUP(A1,Sheet2!$A$1:$C$15,3,FALSE)
(Note I used C15 as an example in the above VLOOKUP. It should be the number of rows you have on file 2)
More info:
https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1

Is there a way, using built-in Excel functions only, to check one set of data against another?

More specifically, assume there is a full list of names and addresses on a worksheet. There is also a second worksheet with a subset of the names from the full sheet, with newly updated addresses.
Is there a way to loop through all of the names on the full sheet, check if it matches any of the names in the revised sheet, and, if so, update the relevant address on the full sheet with the relevant new address from the second sheet?
I managed to get it to successfully check the names from sheet1 against the names on sheet2, but I don't know of a way to tell the formula what cells to get the address information from in the event of a match.
The format of the cells is firstname, lastname, address1, address2, city, state, zipcode for both worksheets.
VLOOKUP is the function you are looking for. Once you have mastered this, you might want to look into the INDEX AND MATCH functions, which can achieve the same result more efficiently and (sometimes).
For complete description of VLOOKUP, see Microsoft's support page for VLOOKUP
It's very helpful to have a unique id code for each individual. If you have one, include it in column A of both datasets. If you don't have one, you can construct an ID field, but you'll need to do some manual work to make sure it is unique. (Suggestion on how to go about constructing ID code at end of answer.)
Put the ID in column A. Columns B-H will have your other fields, so address1 will be in column D.
You're going to want an absolute reference for your original data. Let's call the worksheet with old data Worksheet1 and the one with the new data Worksheet2. Then the reference for original data (including ID code) will be Worksheet1!$A:$H
VLOOKUP will match the ID code in new worksheet with the one in the old, and then pull data from the column you specify. To look up the matching address1 for the first person in the new dataset, you'd use this formula:
=VLOOKUP(A1,Worksheet1!$A:$H,4,0)
where
"A1" is the id code that you want to match to.
"Worksheet1!$A:$H" is the original data
"4" tells excel to look in the 4th column ("D") in the original data
"0" tells excel to only return an error if there is not an exact
match. (This is important.)
Do this once for each column that you want to compare (address2 will look the same as address1, but will reference column 5 instead of column 4). Havind done this, you can copy to the rest of the rows in your new worksheet.
Procedure above will pull old data into appropriate row of new worksheet. If you just want to know if there is a change to a particular field, you could do something like:
=IF(D1=VLOOKUP(A1,Worksheet1!$A:$H,4,0),"","changed")
There are obviously lots of ways to refine this and condense the information.

How can I use a drop down list to change the reference in a formula in Excel

I have a workbook that has many sheets. Most of the sheets contain raw data. One sheet referred to as "Quick Stats" contains a bunch of various tables that take the raw data and give it meaning, such as: how many tests were taken in January; which teacher gave out the most tests; etc.). I'd really like to be able to display the stats for any given period without having to create additional sheets or tables. I'd like to select a period and have all the formulas on my stats sheet display values from the sheet that contains the data for that period.
Is there a way to have a cell (maybe a cell with a drop down list?) whose content becomes the reference point in the formulas?
For instance my sheets are named AY 13-14 (aka. academic year 2013-2014).
So if I have a formula like below
=SUM('AY 13-14'!C:C)
how can I make the sheet name of 'AY 13-14'! be the result of the value of a cell and have the formula reference the correct sheet?
Is this even possible?
Your formula will have to use INDIRECT reference based on the value of the cell with the drop down list.
For example: if you have your drop down list in the cell QuickStats!A1, then your formula will be
=SUM(INDIRECT(QuickStats!A1 & "!C:C"))
(Your drop down list would have to contain names of data sheets, e.g. AY 13-14 etc)

Resources