Excel INDEX + MATCH and LEFT/RIGHT - excel

So I have this:
=IFERROR(SUM(INDEX('Roster Hours'!$B$6:$AB$36,,MATCH($J17,'Roster Hours'!$B$5:$AB$5,0))),"")
J17 is a name, and it pulls their total rostered hours for the month from a mostly VB generated spreadsheet. I'd like to leave that alone.
This issue is, the VB has code to replicate fortnights, to save the user entering them. When it does this, it places an asterix at the start, and it gets ignored by the formula.
Is there a way to modify the code above to trim the first character. I know the code to trim it, but applying to a range of numbers is the issue.

Related

Excel converts formulas stored with # automatically, how can I controll that

I find myself amazed by the magic of Excel non-transparent automatization. I have office 365.
I have the setup below, column P contains "Current value" that is taken into consideration for reports and column Q (Current formula) actually contains formulas that can be restored to P by removing the #.
Let's take cell P58 as an example:
If I write in P58 the formula =RIGHT([#[Current formula]],len([#[Current formula]])-1) and hit enter, Excel automatically converts it to =365.25/12/7 and sometimes converts it directly to the result of that function 4.35. Yes I said sometimes because I have not figured out the pattern.
I would expect after adding the =Right( formula that I would need to Copy - Paste special Values, and then replace = with = in order for Excel to recognize it as a formula.
The problem is this only happens for one file, my coleague has not been able to replicate it on other files.
I don't have any VBA triggers on Sheet or ThisWorkbook
How can I controll these actions that Excel does?
Oh and by the way, I have Fill formulas in tables to create calculated columns OFF:
Let me know if I need to upload a Demo video, I'm not sure how I would do that on stackoverflow at the moment.

Unable to convert text to Numbers

I've been given an excel to import on Database, it was exported from an Access DB. in the excel there's a column type_class, in one excel it's good(sheet1), but on another excel which I moved to sheet2 to make VLOOKUP function, I can't tell whether it's a text or a number column from the first sight. the upper-left green-thing is not showing on all cells. but, using ISTEXT function result in text. below is the original column without any changes or formatting, as well as ISTEXT result.
when I use the column in a VLOOKUB function to transfer the Name to the first sheet, only (1010, 1101, 1102,....), hence the cells with the green-mark on the upper-left corner.
I can easly format the key in sheet1 using text-to-columns, cell formatting, and any other way.
but I cannot change the column in sheet2, I tried:
Text-to-Columns
Cell Formatting
VALUE(text), CLEAN(text), TRIM(text), TRIM(CLEAN(text)), CLEAN(SUBSTITUTE())
Multiply by 1
but only the cell with the green-mark changes to a number, the rest stays the same. I browsed the internet but didn't get a solution either.
Edit:
I uploaded what is need to test the case on the drive. you can find it here
Help Appreciated
For your digit strings that you can't convert to text, from the comments it seems there are extra characters in that string not removable by TRIM or CLEAN.
Determine what those character are
Assume a "non-convertible" digit string is in A1
Enter the following formula
B1: =MID($A$1,ROWS($1:1),1) and fill down
C1: = UNICODE(B1) and fill down
From this you can determine the character to use in a SUBSTITUTE function.
For example:
From the above we see that the character code that we need to get rid of is 160.
So we use:
=SUBSTITUTE(A1,CHAR(160),"")
or, to convert it in one step to a number:
=--SUBSTITUTE(A1,CHAR(160),"")
Note If the character code is >255, use UNICHAR instead of CHAR in the SUBSTITUTE function.
Without an example, I use value() to convert what excel takes as text like so:
=value(left(“10kg”,2))
Or the following also works:
=left(“10kg”,2)*1
Note those double quotes should be the straight ones - sorry smartphone is not always smart...
And if leading or trailing spaces are an issue, then trim() is one solution.

COUNTIF formula counts values that don't match

I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)

Removal of Duplicate Values - Leading Date

I'm trying to remove duplicate values from my workbook, but the issue is that the same entries, the one I am attempting to keep has the year leading as seen below.
I've tried using a VLOOKUP (below) but since it's not a exact match, I used TRUE, which doesn't return the value I really want and it would take another step to remove the value without the leading year.
=VLOOKUP(F2,F2:F657,1,TRUE)
Any and all help would be appreciated!
How about something like this:
{=IFERROR(VLOOKUP(F2,F2:F657,1,FALSE),INDEX(F2:F657,MATCH(F2,SUBSTITUTE(F2:F657,LEFT(F2:F657,7),""),0)))}
This works as follows: (1) first it checks if the vlookup finds a match. If that's not the case then (2) it will try to find a match in the list by removing the first 7 characters (year + space + hyphen + space). So, the above solution assumes that the first 7 characters must be always remove (this solution is not flexible to the length of the characters that need to be removed).
Furthermore, the above solution assumes that you have an Excel version which knows the formula IfError (requires Excel 2007+). Otherwise, you can substitute that with a complete If formula.
Note, that the above formula needs to be entered as an array formula. So, you need to press Ctrl + Shift + Enter to enter the formula. For more information on array formulas have a look at Microsoft's website here: https://support.office.com/en-us/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7

How to remove a single Leading space in the numeric column in Excel 2013

I really tried a LOT with in-built functions and also with google search but none of the ways doesn't worked out for expected result.
My exact problem is:
I've few numeric columns which i got from a website and copied directly into excel.
In those columns there is a SINGLE Leading space at the beginning of each number in the cell of the entire column. Example 523946.00. In this number there is a single space before the digit 5.
I tried a lot with TRIM and SUBSTITUTE in-built functions but nothing able to resolve my problem of removing spaces.
And also my expectation is when i select two or multiple cells in the same column(spaces removed) then automatically Excel should show or display the AVERAGE: <Average value> SUM: <total Sum> COUNT: <count value> at the below status bar or bottom ribbon.
Say, AVERAGE: 175.49 COUNT: 2 SUM: 350.98
This type of information is not showing at the bottom. Only i'm able to see COUNT: 2 alone....why?
I want in General Format only. No any special formats.
I'm using MS Excel 2013
Edit:
You can actually just use find and replace.
Copy one of the trouble cells.
Select all the cells containing non break space, and select find and replace.
Paste the copied cell into the find bar, delete everything but the last character (asuming that is the non breaking space).
Leave the replace bar empty and press replace all.
This removes all non breaking spaces. :)
**Old Solution:**You can add nothing with paste special to the whole column where the spaces occur.
First copy an completely empty cell. (! remember this step)
Then select all cells in the column and right click and select paste special.
Then select "add" almost at the bottom (see picture) and press ok.
This will make excel reevaluate the values as if you had modified in and entered the value manually. Excel then correctly converts them to numbers. :)
First make sure you have the column Formatted as you would like. Make sure it is a number with 2 decimal places (or how ever many you need), then also make sure that there is no Indents (Maybe you think the Indent is a space?) And that you have it Aligned to the Left, Or where you want the Data To be. This alone should take care of your issue.
If that doesn't work here a list of possible solutions.
=Value(Trim(A1)) ' Removes all white space before and after the text in A1
=Value(Clean(A1)) 'Removes all non printable Charactersin A1
=Value(SUBSTITUTE(I3," ","")) 'Substitutes(Replaces) all instances of " "(Space) with ""(nothing)
'****Note: With Substitute you can also specify how many
' Substitutes(Replaces) to make of the value
=Value(SUBSTITUTE(I3," ","",1)) ' Same as above but with only remove the FIRST space
=Value(Trim(Clean(A1))) ' Removes all white space before and after the text
' after removing all Non-Printable Characters
=Value(Trim(Clean(Substitute(A1," ","")))) ' Removes all white space before and after the
'after removing all Non-Printable Characters
' And after replaceing all spaces with nothing
=Value(Right(A1, Len(A1)-1)) ' This takes the End of your text by the number of characters
' in the value Except the First (In your case should be the Space)
=Value(SUBSTITUTE(I6,CHAR(160),"")) 'To help with the non breaking spaces also.
If nothing works could you please share Why you would like to remove the space? As in what you are trying to do with the data? As maybe that will open more solutions
With Ole Henrik Skogstrøm's Suggestion added Value around the functions to get the result as a value.
It may be Excel is treating your cells as text data. Is the fun Green Triangle present?
This is a common problem in excel. Forcing numeric is easier than text. Just format a column as number or General and then put in the function value() into the cells.
Things can be cleaned up from there with Copy/Paste Special values and then remove the original column.
Using Excel 2007
brettdj answered this for me. This is what worked for me and it was SIMPLE!!
To remove the CHAR(160) directly without a workaround formula go to
Find & Replace
in the Find What hold ALT and type 0160 using the numeric keypad
then Leave Replace With as blank and select Replace All
In your case, since you always have a string of numbers, where you want to remove just the first character (a space), this formula should work:
=RIGHT(A1,LEN(A1)-1)
The numbers can vary in length, important is only, that you want to remove just 1, (or 2, or 3 etc) characters. It will still work. {If you had 2 empty spaces in front, then you would use in the formula -2, if three -3, etc)
However, if you had always a different amount of blanks in your string of numbers, like I had, you could use this formula, which worked for me:
=VALUE(SUBSTITUTE(TRIM(A1),CHAR(160),""))
,assuming that the issue you are facing is code "160".
That you can find by typing: =code(A1), which in my case gave me the result "160". Therefore char(160) in the formula above.

Resources