Excel Formula for dynamic columns - excel

I'll try to make sense of this the best I can. I'm pretty horrible at making things clear. :) So...here it goes....
I have a spread sheet that is a list of seeds I have for growing peppers. Here are the columns I have, and I will explain more after.
Crop | Color | Generation | Species | Source | Scoville | Flavor | Heat | Notes | 2012 Type | 2012 Name 1 | 2012 Name 2 | 2013 Type | 2013 Name 1 | 2013 Name 2 | etc.
Ok. So "2012 Type" is a list that will contain either a blank, "N", "O", or "M". All I care about is whether it is blank or not for this question. If it is NOT blank I want to highlight the Crop name with a green background to show that I have grown this crop. To do that through the Conditional Formatting is a no brainer. However, my issue begins when I, as usual make things more complicated. When I add "2013 Type", "2014 Type", etc. I want to check for those also. So then my formula becomes an OR; is there a value in 2012 or 2013 or 2014, etc. Part of question is that. How do I write a formula that is dynamic enough to pickup the new fields I add each year...2015 Type, 2016 Type...etc.?
I also have a ton of other stuff going on, but I think I may have that figured out...sort of.
Thank you for your help, appreciate it.
Edit: Okay. I feel I need to explain how I am trying to develop my whole worksheet, one to check my thinking, and two to clear up the goals.
In addition to what I have explained above, I have tabs that read 2012, 2013, grown, not-grown, MasterList, and Criteria.
MasterList is what we are talking about here.
Criteria is what I am using for an advanced filter to copy crops that to the appropriate sheets. So, if I have a a crop marked in column "2012 Type", then it will be copied to the 2012 sheet. It will also be listed under the tab Grown. Same if it were marked under "2013 Type" etc.
Basically, I am using tabs to filter out specifics from my MasterList so that I can find what I'm looking for quickly, or view everything as a whole.
Once again, I am great at making things over complicated. Couple that with the fact that I am still fairly new to Excel coding...and you have a disaster. :)
Thank you all for listening. :)

Try using a COUNTIFS formula in conditional formatting, e.g. this formula
=COUNTIFS($1:$1,"*Type*",2:2,"<>")
....will count the number of cells in row 2 which have some value....and where row 1 has "type" contained in the header row for the same column.
For your condition you want to know whether the result of the COUNTIFS formula is zero or not (zero signifying no entries in any of the type columns for that row) so for green use
=COUNTIFS($1:$1,"*Type*",2:2,"<>")>0
Note: COUNTIFS is only available in Excel 2007 and later, for earlier versions you can use this formula
=SUM(ISNUMBER(SEARCH("type",$1:$1))*(2:2<>""))>0

Actually for an annual exercise I would just go for amending the conditional formatting as part of your procedure when you add the columns with the OR in it as you mention it.
The condition should be (as you probably already know):
=OR(ISBLANK($J2),ISBLANK($M2))
I'll have another thought about making it smarter but I have a feeling already that will involve some more coding and such, making the effort for this bigger then the benefit for the annual updates.

You might consider reformatting your data so that it only grows in the row direction and not the column direction. I'm thinking
Crop | Color | Generation | Species | Source | Scoville | Flavor | Heat | Notes | Year | Type | Name 1 | Name 2
Then you could use pivot tables, formulas, and array formulas to present the data in various ways.

I would create a worker column(you can always hide it later) that concatenates all your Type columns together into one column:
=CONCATENATE(K2,N2,Q2,T2,W2,Z2,AC2,AF2,AI2,AL2,AO2,AR2,AU2,AX2)
=$A$2:$ZZ$10000
=IF($A2="",FALSE,TRUE)
It's important that you enter the formulas and conditional format formulas and applied to range accurately - with the correct syntax(notice the use of $).
Good Luck.

Related

How to merge data of two excel sheets into the third sheet with some cleansing operations

I have a homework assignment where I have to merge data of two excel sheets by performing some cleansing operations using formulas.
Sheet 1:
OrderID | Full Name | Customer Status
1001 Waqar Hussain Silver
2002 Ali Moin Gold
Sheet 2:
OrderID | First Name | Last Name | Customer Status
A1003 Junaid Ali 2
A2004 Kamran Hussain 1
Sheet 3:(Combined Sheet) - Expected
OrderID | Full Name | Customer Status
1001 Waqar Hussain Silver
2002 Ali Moin Gold
1003 Junaid Ali Silver
2004 Kamran Hussain Gold
There are probably a lot of ways to do this. First make sure the data is cleaned. If you are already 100% positive the data is clean you can skip this step. If you aren't sure it's better to be safe than sorry. For each column create a new column using the CLEAN and TRIM functions to remove any non-printable characters and any extra spaces. Something similar to =TRIM(CLEAN(A2)). Then drag the formula for each cell.
After this in order to merge the data together we need something to join on. The full name seems to make the most sense. On sheet two we'll write a new function to join the first name and last name together. The =CONCAT formula should work.
=CONCAT(First Name, " " ,Last Name). Make sure to note the extra space added by the quote. That way it matches the Full Name from Sheet 1. Looks like we'll also need to strip out the letter from Order ID in sheet 2. I'm going to assume that all Order IDs are 5 characters long. If this isn't true then you'll need a different solution. You can use =RIGHT(A2,4). This will grab the right 4 characters from the text string.
At this point let's create a distinct list. Copy the Full Names from Sheet1 and Paste them on to sheet 3. Copy the Full Names we created on Sheet2 and Paste VALUES onto sheet 3 below the full names from sheet 1. Then select all the rows in the column and go to the Data tab. Click "Remove Duplicates". This will now generate a distinct list of values.
We can now merge the data together using an INDEX MATCH. There are lots of great tutorials on how to use INDEX match in combination. It's a little long to explain on this thread, but this is a great thread explaining how it works. It's worth taking 10 minutes to fully understand it because it is a formula you will use thousands of times throughout your life.
https://www.deskbright.com/excel/using-index-match/
Let me know if I can clarify anything.
Best,
Brett

Searching in Excel for certain values, if found give text from cell to the left of where we found the value

First let me explain what I want to achieve.
I currently have an Excel like this:
Names | Standards
James | Standard 1
James | Standard 2
James | Standard 3
Francis | Standard 1
Francis | Standard 2
Francis | Standard 3
Leon | Standard 2
Leon | Standard 3
Peter | Standard 2
Michael | Standard 3
And I want to create something like this:
Standard | Name 1 | Name 2 | Name 3 | Name 4
Standard 1 | James | Francis | |
Standard 2 | James | Francis | Leon | Peter
Standard 3 | James | Francis | Leon | Michael
My real Excel has more than 300 standards, so I would like to automate this using Excel Formula. I know this is possible, but I haven't used Excel in a while, so I could use a push in the right direction.
Couple of things I need (I think):
Need to count how many times people in the names column mention a standard. So I want to know that I need 2 names for standard 1 and 4 for standard 3. I think I can do this by using the COUNTIF method.
We need to search for the location of the standards. I think I can do this by using the Match function. This gives us the location of the first match in my original Excel. By sorting my original Excel a-z and combining it with the countif result I know where all the matches are (first match + countif = location of the last match, and everything inbetween is also that standard).
For the first name that mentioned a standard, I will reference the cell left of the first match (because the names are in the cell to the left of the standard I found). For the second name I will reference the cell left of the cell below the first match. I keep doing this till I find as many names as Countif mentioned. So I need an IF statement that makes sure that if 2 people mention standard 1 only gets 2 names and 2 cells with a "".
How will I reference the cells? By another if statement that uses this: Excel Reference To Current Cell , Correct me if I am wrong, but can't I then just say THIS.CELL=cell location I found (probably should use INDIRECT here?).
This is just me brainstorming, but I would love to know if people have any other ideas for my problem or have some feedback for my current plan.
An important thing to mention is that I want to do this using Excel Formula. I do realise that this isn't always the best, but VBA is not an option atm. I am also not worried about performance issues, because I think i'll just copy all the values after I found all the names using formulas.
Thanks in advance!
Depending on how you want to have the layout, I think you should use a pivot table. Drag the 'Standards' and 'Names' fields to the 'rows' data box and then right-click on a standard, click 'Field Settings' - 'Layout and Print' - 'Show item labels in tabular form'. (See example below.)
If you definitely need the data in the format in your question, I would edit the pivot table by dragging the 'names' field to the 'columns' data box. Then drag the 'standards' field from the field list above a second time and duplicate it in the 'values' box (see example below).
In the space underneath the pivot table, use an IF formula to only copy the name if there is a 1. This kind of approach will obviously be quite fragile, so if you can make do with the first approach, I think you will run into fewer problems in the future.

How do I calculate a Sum based on multiple If's in Excel?

Background is that I'm making a budget spreadsheet. I have different bills due on different days. (ie. bill due on Monday and bill due on the 10th)
I want a function that will place the appropriate amount of money going in/out in column D and the description of why the money is going in/out in column E.
Currently I have two different formulas that I created (probably incorrectly).
Formula for Column E: (Already is in the document and seems to work fine other than that fact that I cant add additional text to the cell)
=IF(DAY(C36)=7," Amy Pay","")&IF(DAY(C36)=22," Amy Pay","")&IF(DAY(C36)=8," Family Bills","")&IF(DAY(C36)=6," Dollar Shave Club","")&IF(DAY(C36)=2," Amy Cap One VISA","")&IF(DAY(C36)=3," Chase VISA","")&IF(DAY(C36)=8," Being Smart","")&IF(DAY(C36)=17," Gym","")&IF(DAY(C36)=11," Netflix","")&IF(DAY(C36)=19," Cap One MC","")&IF(DAY(C36)=29," CenturyLink","")&IF(DAY(C36)=6," Haley Cap One Visa","")&IF(DAY(C36)=10," SRP","")&IF(DAY(C36)=23, "Car Payment","")&IF(DAY(C36)=30, "Rent","")&IF((B36)="Mon"," Monday","")&IF((B36)="Fri"," Friday","")&IF((B36)="Fri"," Haley Pay","")
Formula for Column D: (not in the column yet, as it doesn't work how I want)
=IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400","")
http://imgur.com/IBINweh
      
The problem is that in column D, rather than providing a sum of the numbers, it lists the numbers in the column.
http://imgur.com/rPDS5h2
      
I had a suggestion to add =SUM( in front of the IF( function, but when I do, #VALUE! is what results in the field. Using this formula: (view image by changing appended text to /CVs0f1v )
=SUM(IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400",""))
Any ideas on how I can get all the to populate and sum appropriately?
Forgive my Non Excel Guru knowledge - trying to learn. :D
-Amy
If you take all of the options from your first working formula and change the method retrieving them, you will have a much more versatile worksheet that can easily accept new additions and schedule modifications.
    
In a couple of unused columns to the right, pit in the day-of-month and the action that occurs. I'm using columns Y & Z. You have two events occurring on the 6th so I put them together.
In a couple of other unused columns use the day-of-the-week and associated text.; I've used columns V & W. The default for Sunday is 1.
In E36 use this formula,      =TRIM(IFERROR(VLOOKUP(DAY(C36),$Y:$Z, 2, FALSE), "")&" "&IFERROR(VLOOKUP(WEEKDAY(C36),$V:$W, 2, FALSE), "")) 
Fill down as necessary.
If you want the day-of-the-week in column B, use =C36 and use a custom number format of ddd or dddd.
References:
  VLOOKUP function  WEEKDAY function
You are concatenating text strings that look like numbers. You probably want to be adding real numbers:
=SUM(IF(DAY(B40)=7,1474.22,0) + IF(DAY(B40)=22,0) + ...
although, whenever I see a formula as complex as what you have, I would consider looking for a different solution -- Vlookup comes to mind.
In addition, with a VLOOKUP table, you would have seen that you have some conflicts -- e.g: you list the same condition of B40=8 to return two different values; and the same condition of A40 = Fri, to also return two different values.

Excel Advanced filtering multiple columns with multiple acceptable data combinations

I have a large data set with 4 columns of interest all containing text, namely pokemon moves. The columns "move 1" through to "Move 4" each contain a different move, and each row differs in the combination.
eg.
" A | B | C | D | E".
" 1 Pokemon | Move 1 | Move 2 | Move 3 | Move 4".
" 2 Igglybuff | Tackle | Tailwhip | Sing | Attract".
" 3 Wooper | Growl | Tackle | Rain Dance| Dig".
~ 1000 more
My issue is this:
I wish to filter this data set for rows (pokemon) containing a certain combination of moves from a list.
eg. I want to find which pokemon have both "Growl" and "Tackle". These moves can appear in any of Moves 1 to 4 (aka order of the moves is unimportant)
How would I go about filtering for such a result. I have similar situations in which I would want to search for a combination of 3 or 4 moves, the specific order of which is not important, or also search for specific pokemon possessing a specific combination of moves.
I've attempted to use functions such as COUNTIF without avail.
Help / Ideas are much appreciated
There are a number of options for advanced filtering in excel that you might consider:
Option 1 - Advanced Filters
Advanced filters give you the power to query over multiple criteria (which is what you need). You can also easily do it as many times as you want to generate the final datasets using each filter. Here is a link to the advanced filter section for Microsoft Excel 2010, which is virtually identical here to 2007. It would be a great place to start if you want to move outside of just using basic formulas.
If you do go down this route, then follow the directions on the site in terms of steps:
Insert the various criteria that you have selected in the top rows in your spreadsheet and specify those rows in the list range
Set the criteria range to the place holding all your data on a single worksheet
Run the filter and look at the resulting data. You can easily do a count on the number of records in that reduced data set.
Option 2 - Pivot Tables
Another option that you might look at here would be to use Pivot tables. Pivot tables and pivot charts are just phenomenal tools that I use in the workplace every day to accomplish exactly what you are looking for.
Option 3 - Using Visual Basic
As a third option, you could try using visual basic code to write a solution. This would give you perfect control as you could specify exactly the ranges to look at for each of the conditions. Unfortunately, you would need to understand VB code in order to use this solution. There are some excellent online resources available that can help with this.
=COUNT(INDEX(MATCH(B2:E2, MoveList, 0), 0)) > 0
will return TRUE if any of the values in the range B2:E2 (Moves 1 through 4) are in the range defined by Move List. You want to use a named range so that you can easily copy this formula down for all of your thousand rows.
If you remove the last part that checks whether the COUNT() value is greater than zero, you get:
=COUNT(INDEX(MATCH(B2:E2, MoveList, 0), 0))
which will return the number of moves that the Pokemon has that match a move on the move list.
MATCH() takes three arguments: a lookup value, the lookup range, and the match type. I don't fully understand why, but wrapping that part of the formula in INDEX() seems to let you use an array for the first argument. Maybe someone here can provide a better explanation.
In any case, the formulae above do appear to solve the problem.
Finally, if you're only checking for a few moves, instead of using a confusing formula and a named range as above, you could just make a column for each move that you want to check for, e.g. "Has Growl?" and "Has Tackle?". You would then just use =COUNTIF(B2:E2, "Tackle") and =COUNTIF(B2:E2, "Growl"). You could then make another column that sums these columns and filter out the zero values to display only Pokemon who have Tackle or Growl.
I looked at these two pages when researching how to accomplish this:
https://www.excelforum.com/excel-general/786407-find-if-any-value-on-one-list-exists-on-another.html
https://www.deskbright.com/excel/using-index-match/

Excel - Enormous Vlookup Concatenate required for Minor Procedure

I have a lot of excel data spread accross 32 documents in an identical format that list information. The combined total would be over 6 million rows.
I have another document that contains a few thousand rows. The CONCATENTATE of Column C,E and L in this new document could be the same as the CONCATENATE of column D, F and N in any of the other 32 documents.
I want to find information that is the same and grab the hole lot of it for each row in the small document from each of the larger documents.
At the moment this required that I concatenate the info on each of the larger documents, remove all spaces and punctuation and use 32 IFERROR calculation each containing a VLOOKUP. The last one took all night. All others have crashed the computer.
The must be a better way of doing this???
EG.
Small document:
TITLE1 | TITLE2 | TITLE3
Larger documents (all 32)
FACT1 | FACT2 | FACT3 | TITLE1 | TITLE2 | FACT4 | TITLE3
If the concatenation of Title 1,2 and 3 of the small document finds the same info in any of the concatentations of title 1,2 and 3 (removing all spaces and punctuation) from the larger document. I want to copy in all the information for that row from the larger document including the titles and facts adjacent to the row of info in the smaller document.
Ai yai yai. Excel is not made for doing something like this. It's simply the wrong tool. So assuming that you are stuck with that, I would try creating an Access database, linking each spreadsheet you need, then writing a query. I'm not totally clear on what you want to do with the matched info, but you could export it to a new spreadsheet, or link a spreadsheet to that query.
In Access (2007+), go to the External Data tab, click on Excel in the Import section, then select Link. If that is still too slow, you will need to copy the spreadsheets in and perform the query.
Would be much better in a database rather than Excel, but to make it work efficiently in Excel you need to use the binary search option (sorted approximate match) of VLOOKUP or MATCH. This is several orders of magnitude faster than linear (unsorted) search:
1. Create additional columns doing the concatenation etc on the 32 sheets and the small sheet.
2. Sort the data on the 32 sheets using the concatenated column
3. Use a Double VLOOKUP with IF to turn the Approximate match into an exact match, something like this
=IF(VLOOKUP(PartNumber,PartsList,1,TRUE)=PartNumber, VLOOKUP(PartNumber,PartsList,4,TRUE), “Missing”)
See http://fastexcel.wordpress.com/2012/03/29/vlookup-tricks-why-2-vlookups-are-better-than-1-vlookup/
for a more detailed explanation of this formula.
If there is a structure so you know in which sheet you need to search, you could see if the INDIRECT function can help you. Otherwise, I suggest you import the data in a database (such as Access) and then query your data.

Resources