I have an Excel file which includes lots of rows of information. I have actually a single problem which is I can't get the parent of each cells according to the information in the cell. It looks like this
In the image, you can see that A has no parent and its' children are A01 and AB and more and more like AC and AD. Is there any way for handling this issue with excel-formulas?
Assuming that your sample data is true to the format of all your data (there is either 2 numbers at the end of each parent or only an extra letter) then the following formula will work:
Given formula is set to look at data in cell A1, you will have to drag and auto fill the formula down for all rows.
=IF(OR(RIGHT(A1,1)="0",RIGHT(A1,1)="1",RIGHT(A1,1)="2",RIGHT(A1,1)="3",RIGHT(A1,1)="4",RIGHT(A1,1)="5",RIGHT(A1,1)="6",RIGHT(A1,1)="7",RIGHT(A1,1)="8",RIGHT(A1,1)="9")=TRUE,LEFT(A1,LEN(A1)-2),LEFT(A1,LEN(A1)-1))
It works by checking if the last character is a number (with this data excel treats it as text so we have to check for each number as if it is text), if it matches a number then show the parent minus the two right characters otherwise show the parent minus one character.
Okey I think I found the answer. Here is my formula
=IF(LEN(B2)=1;"NULL";IF(LEN(B2)=2;LEN(B2;0);IF(LEN(B2)=3;LEFT(B2;1);IF(LEN(B2)=4;LEFT(B2;3);IF(LEN(B2)=5;LEFT(B2;4);IF(LEN(B2)=7;IF(B2;5)))))))
With this formula, I check the length of the characters in cell and get the first part of that string instead of deleting the last indexes because of there are also some string values.
Because of there are some rules with my product codes, I figured out how they are changing and I got the part of the code by their sizes. Thanks for replies, they helped to find this solution.
Related
This pictures shows my table and formula's yield
I have used following formula to extract result from a table.
Its working perfectly fine but I am hoping to level up my understanding of Excel formulas.
The trouble is that I use IF in Excel way to often.
what I wanted to know is if its possible to use a different approach, something that can work similar to if but is perhaps more sophisticated.
=IF(OR(J2="08L",J2="08R"),IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$34,0)),"LAM",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$35:$E$35,0)),"West",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$36:$G$36,0)),"East",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$37,0)),"SFD",NA())))),0)
I very much appreciate any help.
Now that there is an example, I think this is a good question. You've recognised that your formula is fairly messy and also can't be easily expanded if there are more routes.
The problem is that Excel is very good for searching for a value in a single row or column, but not as good for searching for a value in a block of data.
You can simplify this problem by creating an additional column that has each entire route in a single cell. You can do this just by concatenating values. In your example, use column H:
=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2
This will create a string with the entire route in a single cell. Spaces are added in between each part of the route to make sure you don't accidentally create a sequences of letters that matches part of another route. It doesn't matter if there are blank cells, there will just be some extra spaces at the end which doesn't matter. Fill this down the column to get the entire path for each route in a single cell.
Then, you can create a formula that tries to find the 3 letters anywhere in any of the full routes.
=INDEX($A$2:$A$5,MATCH("*"&left(I2,3)&"*",$H$2:$H$5,0))
This formula is basically a deconstructed vlookup. It determines where the 3 characters can be found in column H, then gives back the corresponding value from column A.
The MATCH function tries to find the left 3 characters of I2 in column H. The MATCH function normally tries to find a complete exact match (with the last parameter being equal to 0), but we can just add wildcards to the search value. The MATCH function then returns the index of the range where it was found. I.e., if it was found in the 2nd cell of the range H2:H5, it returns the number 2.
The INDEX function then just gets a value from a range based on an index. In this case, it will get the 2nd value from range A2:A5.
I have two columns of cells that have irregularly formatted addresses.
I need:
1) just the zip codes to be copied into a new column;
2) the rows that do not contain zip codes to be either highlighted or empty so that I can easily identify which ones are missing.
This seems like it would be simple to do, but I can't figure out how to have Excel just find all instances of 5 consecutive numbers. Currently they are formatted as text so that the zero's are displayed. Any help greatly appreciated.
Here's what it would be to start with:
Here's what it would look like when done (highlighting optional):
You don't have Regular Expression in normal Excel. You would have to go into VBA to do that. However, for your case, there's an easy pattern: notice how the zip code is after the last space, and it's always 5 digits long? The challenge then become finding the index of this last space and extract the 5 characters that follow it. It will be clearer if you split them into 2 formula
// C3 (index of last space character):
=FIND("|",SUBSTITUTE(B3," ","|",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))
// D3, the 5 characters after that.
// Return an empty string if the address doesn't match the pattern
=IFERROR(MID(B3,C3+1,5),"")
Another approach to what Zoff Dino wrote is to break it out a bit as shown below:
In cell C3 enter the formula you see in the formula bar
Drag that down the row set and over 1 column (so it runs for column B as well)
In column use this formula: =IF(AND(C3="",D3=""),"",IF(C3="",D3,C3)) and drag it down.
This will account for all possible situations you have shown and not error out on you (unless other patterns emerge).
You can then use conditional formatting to highlight the rows with no zip code as shown in the picture:
Because of floating point values, I cannot add a string of cells that contain values such as:
0.08178502
0.09262585
0.13261762
0.13016377
0.12302067
0.1136332
0.12176183
0.11430552
0.09971409
0.125285
Even if I try adding the first two through a sum formula or auto sum through selecting them, excel spits out an error. I have googled this like crazy and tried to change number formats. Is there a function that can allow me to add this information ?
Screenshot:
The spreadsheet is available on my Dropbox.
Those numbers are all preceded by a NBSP (Char Code 160). So, in order to sum them, you have to remove that. Many solutions. Here's one:
=SUMPRODUCT(--SUBSTITUTE(A1:A18,CHAR(160),""))
If a formula like:
=A1+A2+A3+A4+A5+A6+A7+A8+A9+A10
produces:
#VALUE!
then your "numbers" cells contain non-visible characters.
They must be removed before the formula will work.
If the cells contain text strings and not actual values you will need to convert the text to numeric values before performing any calculations. The function "=value(cell)" will bring the numeric value.
e.g.: A1 contains "000.12345678" (or some other non-numeric presentation of numerals)
In cell B1 type: =value(a1)
Cell B1 now operates as the real number 0.12345678
Oddly enough, the fact that it said 0.xxxxx in all numbers vs. .xxxxx is what the issue was. I'm just sharing that for folks who google/search and have same issue.
All I had to do was select that whole row and do a search in replace for "0." and make it just "." and now my numbers were usable in equations. For some reason the adjustment of formating as many searches suggested wasn't working
I'm not sure why my VLOOKUP formula is not working like the screenshot below. The value is right there as highlighted. I want to output the value in Column G, but changing the 3rd parameter to 1 or 2 doesn't work.
Help is appreciated. Thanks much in advance.
Formula: =VLOOKUP(B2,$F$1:$G$421,2,FALSE)
One thing you may want to look at.
I notice your data is left justified and that's normally the case for textual rather than numeric fields - it's possible to left justify numerics but it's neither the default nor the general practice.
If they are textual, there's a chance one or more of them may have leading or trailing spaces. That would prevent the lookup from finding a match.
Select (in turn) B2 and F1 and use the arrow keys in the formula box to check this is not the case.
In cases like this, I tend to (temporarily) set B2 to the formula =F1 just to see if it can find a match that's guaranteed (then use CTRL-Z to revert).
If that change results in the lookup working then obviously the (original) B2 and F1 are not the same value, and you need to work out why (hidden spaces, wrong types, and so on).
It looks like you are comparing text to number (see the green triangle in your value cell). You have to convert the value in your source cell or matching cells to same type. To convert source to number use excel function such as int or value. Hope this helps.
Another way to convert text to number format is to multiply by 1 and then replace original text values with these new number values...
If you are doing lookup where you have a mix of text and numbers (i.e. looking up a text version of a number in a list of real numbers) you can also make use of the VALUE function... this will convert numbers stored as text to real numbers.
Embed it like so:
=VLOOKUP(VALUE(B2),$F$1:$G$421,1,FALSE)
If you have a mix of text numbers and text text to look up in numbers/text then you can do:
=VLOOKUP(IFERROR(VALUE(B2),B2),$F$1:$G$421,1,FALSE)
to change numbers stored as text to numbers, but leave other text as is...
I have individual cells in excel with the following content in each of them
http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/m1423.jpg|http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/m1423.jpg
http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/rt2899.jpg|http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/rt2899.jpg
This is one cell in a long row for a dump of data for products within an ecommerce site. A data migration has somehow added the same image more than once to the same product. Each separate image image is separated by the Pipe "|" symbol.
I want to search each cell in this column of the sheet and remove the duplicated image reference and the Pipe symbol.
So the examples above become
http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/m1423.jpg
and
http://www.teng.mossdemo.com.au/wp-content/uploads/images/products/rt2899.jpg
The suggested answer of finding the pipe with SEARCH is a good general answer, however in this instance as the source string is always twice the length of the desired we can just chop it in half with the formula below and drag it down.
=LEFT(A1,(LEN(A1)-1)/2)
In addition to a formula, you can use Data>Text to Columns, which is a good thing to know about. Select the entire column and then you up the dialog. In step one choose "Delimited" and in step two choose the pipe symbol:
When you're finished, delete the first column.
I figured out that this works for some more complex scenarios. I think it should work for this one as well.
=IFERROR(LEFT(C2,(FIND(LEFT(C2,20),C2,2)-2)),C2)
I entered this into D2 and copied it all the way down the column. I then copied and pasted the values back into Column C.
The problem I had was that not all of the cells in my column had duplicate text. Of those that did, the duplications were not delineated by any unique character (There was a single space in front of each duplication.), and the duplicated text was often an incomplete duplication so the length was not consistently symmetrical.
The "20" is an arbitrary number of characters I picked for excel to use from the front of the text to identify where the text started to repeat. There are enough people here who know excel better than I who can explain what the rest of the formula does. I figured it out by poking around.