remove last value if a number otherwise do nothing - excel-formula

I am trying to find a formula for Microsoft Excel:
If the last value from a cell is a number then delete the value from the cell otherwise do leave the same content
=IF(OR((LEN(B2)>1),(LEN(B2)<7)),LEFT(B2, LEN(B2)-1),B2)
this is what I have tried but I am sure this is not the right way to do it, I have values where is 20152 and _thisform1 and _thisotherform so the length it is not the same for cells.
I would want to from from 20152 to 2015 and from _thisform1 to _thisform and leaving _thisotherform as is.

Use this:
=IF(ISNUMBER(--RIGHT(B2)),LEFT(B2,LEN(B2)-1),B2)

Related

Assign a value to a variable [Excel]

I'm making a basic inventory list for my place of work and want to make it easier for future inputs and changes. So far I have inputted all of the model numbers for our inventory, and I was wondering how I could assign a price to the model number, so that it automatically fills it into the cell two cells right. I'm also working with around 50 model numbers, so it would be a lengthy function.
Example:
B E
778740 125.99
778739 120.99
778740
Is there a way that the second "778740" could be automatically filled in? I'm fairly new to excel and I can't find this problem, although I know it is very simple and exists. Even if some one could link me it that would be very much appreciated. Thank you!
Suppose your headers are in row 1, model numbers in column A and prices in column B. You could use the following formula in cell B3 and drag it on down as far as you need. Then what you fill in in column A matches something above, the cell next to it will automatically populate. And otherwise it stays blank, letting you know it is on you to fill it in (though once you do, the formula will no longer be there, so if you later fill in a match above, the magic is gone).
=iferror(indirect("B" & (1+match(A3,A$2:A2,0))),"")
The match function returns an error if nothing is found, and ifError will handle that by leaving your cell blank. If a match is found, we get the value from the corresponding row in column B.

Excel VLOOKUP returning same value in all rows

The vlookup function appears to be broken. It is returning the same value for all lookups, but it should not.
I have it set like so:
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1)
Where the lookup value is in the B column and the result is in the A column.
I use the $ so the rows are not auto-updated to A3:B674 etc as I paste the formula down the rows. However, even if I manually enter that formula into the next row, it is not finding the correct value.
IF i remove the "$", the correct values are found for the first rows where the values fall within the modified range (e.g. Asset_Mapping!A3:B674) but eventually as expected it stops finding the values as the range is invalid.
What am I doing incorrectly here? I have formulas set to auto-calculate.
Without testing on your actual data it's hard to confirm this will work but add the false parameter. This will find exact matches and not the first partial match.
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1, false)
Collating the points together and clarifying the formula
Parameter 1: The value you are looking for
Parameter 2: The table with the data. First column is the value you are looking for.
Parameter 3: The column number of the value you want to show.
Parameter 4: If you want an exact match or partial match.
#Jeeped made the point of ordering data to get more reliable results. Good advice.
Andres has the right idea, but there is a faster way to fix the problem.
If it is returning the same value over and over again for your whole range, you probably have your Calculation Options set to "Manual".
Go into Formulas on the top ribbon and choose Calculation Options. There, you can change your calc method to "Automatic".
Also lookup value must be in first column.
Where the lookup value is in the B column and the result is in the A column.
VLOOKUP always lookup in the left-most column and returns a value from the column number specified. If you want to reverse the lookup/return order then use INDEX(..., MATCH(...))
=INDEX(Asset_Mapping!A$2:A$673, MATCH(A3, Asset_Mapping!B$2:B$673, 0))
Note that you were using a sorted, binary lookup; I've changed this to an exact match lookup which does not require sorted data.
Just in case adding a solution to this topic.
Don't know why in big tables Vlookup and Index+Match tend to show just the value of the first result in all the other cells.
In my case to fix this, after I've copied the formula in the whole range, I choose any cell containing it, press F2 and then Enter. It kind of forces excel to process everything.
I've been working on this for a week with no results. I've created this same spreadsheet for another apartment community without any issues, but for some reason, I cannot get the proper results in this spreadsheet. I've tried vlookup as well, but that didn't help either. any more advice?
Formula
Result and lookup vectors

Using the 'Match' function in Excel to return a cell address

I have a list of numbers in a table that I would like to search for and bring back the cell reference of where that number resides. For example the data looks like:
A B C D
1 1 2 3 4
ok it doesn't come out very well as the first one is the row number and then each number below sits under each letter, so C1 would contain '3'....
If I wanted to return the reference number of C1 in a cell I am using the formula of =CELL("address",MATCH(AU14,C1:AG1)) but this just errors. I have tried to put an Index in there too, but I believe that index only works vertically so this bring back a #N/A result.
Can anyone assist as I've wasted too much time on this already! :)
You are indeed missing an INDEX. And INDEX works vertically, horizontally, or both depending on how it's called.
Here is a formula that works for the ranges in the pictures. Should be easy to modify.
Formula in C5
=CELL("address",INDEX(B2:F2,MATCH(C4,B2:F2,0)))
formula
results
To make CELL work you need a cell reference, e.g.
CELL("address",C1)
The trouble is that MATCH just gives you a number, not a cell reference.
Probably the easiest way is to use the ADDRESS function, so a first try might be
=ADDRESS(1,MATCH(AU14,C1:AG1,0)+2)
That would give you the right answer if AU14 contained 3, but isn't considered to be very good because it wouldn't update if you deleted/inserted rows or columns.
A better one would be
=ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1)
Then you might want to put in some error handling for the case where it's not found
=IFERROR(ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1),"Not found")

Determine whether a cell value's first character is numeric or text?

I am trying to find a good way to use Excel to determine whether a cell's first character is a number or a letter. I am using this to determine a flag that gets marked or not depending on the answer. Here is an example table:
**Status Code**
Inactive 2AJ
Active ALO
Active PN9
Active Y2Y
Inactive 1P9
Essentially, if the beginning character of the Code column is a numeric value, the Status column should show "Inactive". Currently I have this and it doesn't work:
=IF(ISNUMBER(LEFT(B1,1)),"Inactive","Active")
Formula:
=IF(ISNUMBER(VALUE(LEFT(B2,1))),"Inactive","Active")
You were trying to see if a number stored as a string was a number. This fixes that issue.
Please try:
=IF(AND(CODE(LEFT(B2,1))>47,CODE(LEFT(B2,1))<58),"Inactive","Active")
copied down to suit.
This might then be compared against the ColumnA values to flag any discrepancies.

Excel: Leading Zeros on Dates.. Formula to do it for me?

Is there a way to add a leading zero to a date that is 7 digits and should be 8?
7301982 should be 07301982.
I have a column full of these values, and need a way to do so with a formula. Any ideas?
I know this is an oldie, but when I googled for a solution this was the first result.
What I did was:
=concatenate(year(A1),text(month(A1),"00"),text(day(A1),"00"))
Where A1 is a date field.
=text(A1, "00000000") will do it.
Set a custom format of 00000000
Just another thought since this just happened on my new laptop. It could be your windows settings. If you prefer leading zeroes on the month everywhere in windows (like the lower right hand clock) then you can:
Control Panel >> Clock, etc >> Change Date, Time or Number Formats... then set the Short Date to MM/dd/yyyy.
This also carries over to Excel as the first date format. I know it is not a formula exactly as asked, but this is the article I found while searching.
Simply go to custom for the format of the number and select yyyy\m\d and add more m or d to it.
This is a good formula when you need leading zeros so another application sees a 9 digit number.
Add a column to your spreadsheet (Column B if your data is in Column A)
Use this formula in the new column: =REPT(0,9-LEN(A2))&A2&""
Get the 1st cell, then drag down as much as you need.
Remember to copy/paste option 123 to save as data. Otherwise, you'll see data but in reality it is a formula and you will receive reference errors if you try to use the data in column B.
9 digits and column B are variables. You can use any length or any column on your spreadsheet. Just adjust the formula.
Copied from another answer on a different site, worked for my like a charm!
ok. It seems that your dates are formatted as text. This is what you should do.
first, on a blank cell somewhere on the sheet, type the number 1. then, right click, copy.
next, highlight the entire column of dates. right click, paste special, multiply.
all of the dates will have turned into numbers.
next, highlight the date column, and apply the date format that you want.
There is a simple way to maintain the leading zeroes in Excel.
Simply add this to the cell and type whatever value you need and the zeroes will be retained
For ex: If I want 0000000023
Type into a cell '0000000023
That ' symbol seems to retain the zeroes as long as you type it before the values.
This date format MM/DD/YYYY is available if you select the Locale (location): English (Philippines). Try it with one cell and then copy/paste/special/formats the others.

Resources