How to use Data Validation, Number must start with 7 - regex

I want to find a formula that can validate the order number. if the future order numer entered does not start with 7****, it will show a warning. Thank you so much for your help.
https://docs.google.com/spreadsheets/d/1piS3GQ5TzrGAr4VSoSbABkMa-fRm6n_wP16RimegO6E/edit?usp=sharing

Select the range of cells that you only allow texts that start or end with certain characters.
Click Data > Data Validation > Data Validation.
In the Data Validation dialog box, please configure as follows.
1 Select Custom from the Allow drop-down list;
2 For allowing texts that start with certain characters, please copy the below formula into the Formula box;
=EXACT(LEFT(A2,3),"KTE")
And for allowing texts that end with certain characters, please copy the below formula into the Formula box;
=EXACT(RIGHT(A2,3),"KTE")
3 Click the OK button.
Notes:
In the formulas, A2 is the first cell of the selected range; 3 is the number of characters you specified, KTE is the start or end text.
These two formulas are case-sensitive.
If you don’t need case-sensitive, please apply the below CONTIF formulas:
Only allow texts that start with KTE in a range of cells
=COUNTIF(A2,"KTE*")
Only allow texts that end with KTE in a range of cells
=COUNTIF(A2,"*KTE")
And then, click OK button. From now on, only the text string begins or ends with the centain characters you specified can be entered into the selected cells.
In your case, replace KTE with 7 since you want yours to start with number 7.
Yours should be:
=EXACT(RIGHT(A2,1),"7")
You can remove the quotation marks housing the number 7 since 7 is an int, not a string (varchar)
=EXACT(RIGHT(A2,1),7) maybe you can try this if the former fails.

use:
=REGEXMATCH(""&A2, "^7.+")

Related

Deleting ALL cells that contain a certain string, and shifting to the left

I have a customer database file where the data has been input incorrectly and the column names do not match up with the data.
I am using Google Sheets.
To fix this, I need to select all the cells that contain a time stamp, one example of such is:
2016-06-21 08:42:09 UTC
I would like to not only select these cells, but delete their contents, and shift the cells to the left.
This would fix my problem! However, I have no idea if this is possible?
NOTE: These time stamps do not always appear in the same row, and sometimes appear more than once per row.
Here is a visual representation of my problem:
press CTRL + H and do:
\d+-\d+-\d+ \d+:\d+:\d+ .*

Excel formulae: need way to determine if 3rd text character from right is "-"

I have a column of hospital names. In most of them, the last three characters are "-" and the two-letter abbreviation for the state, e.g. "-CA". but some (out of hundreds) have the state name somewhere in the hospital name, e.g. "Texas Tech U Affil-Lubbock" or "Community Health of South Florida".
I'm trying to find a way to make Excel give the last two characters only if the 3rd character from the right is a dash ("-"), but trying to specify that character position seems impossible.
I tried:
=IF(RIGHT(H4,-3)="-",RIGHT(H4,2),"noabbrev") and get #VALUE
=IF(RIGHT(H4,3)="-??",(RIGHT(H4,2)),"noabbrev") and always get noabbrev for
all cells
At this point, I fear I need to use =RIGHT(H4,2) in order to get the bulk of the cells correctly and eyeball/correct the errors by hand.
Am I missing the obvious again?
You can use this formula if H4 is text:
=IF(MID(H4,LEN(H4)-2,1)="-",RIGHT(H4,2),"noabbrev")
If A1 contains some text, then:
=Left(Right(A1,3),1)
should isolate the character you want.

Conditional Vlook up without using VBA

I want to convert an input to desired output. Kindly help.
In the output - the columns value should start from most recent (year)
Please click this to see data
Unfortunately VLOOKUP is not able to fulfill that ask. However the INDEX-function can.
Here is a good read on how to use it:
http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list
This will work for you spreedsheet, if your input table starts at A1 without a header and your output table starts at H3 with the first ID.
You get this by copy&pasting the first column of your input table to column H and then remove duplicates.
{=IF(ISERROR(INDEX($A$1:$C$7,SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3)),"",
INDEX($A$1:$C$7;SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3))}
Let's look at the formula step by step:
The curly brackets tell excel that this is an array formula, the interesting part for you is: when you've inserted the formula (without curly brackets) press shift+ctrl+enter, excel will then know that this is an array formula.
'error at formula?, then blank, else formula
=IF(ISERROR(....),"",...)
When you autofill this formula you probably dont know how many instances of your lookup variable are. So when you put this formula in 4 cells, but there are only 3 entries, this bit will keep the cell blank instead of giving an error.
INDEX($A$1:$C$7,SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3))
$A$1:$C$7 is your data matrix. Your IDs (in your case 125 and 501) are to be found in $A$1:$A$7. ROW(1:1) is the absolute(!) rowID, 3 the absolute(!) column id. So when you move your input table those values have to be changed.
What exactly SMALL and INDEX do are well described in the link above. (Or at least better than I could.)
Hope that clarified some parts,
Tom

Cannot delete non-space whitespace character in excel

When bringing in data into excel via whatever method (import, paste, ...) I sometimes get the following issue. At the beginning of the cell there is an extra space in front of the text. Now I know the usual procedures to handle this namely:
trim(cell number)
and if its not a space character
=TRIM(SUBSTITUTE(cell number,CHAR(160),CHAR(32)))
But this time both of these didn't work. I did try other substitute CHAR's.
AND the character at the beginning is just plain weird. When I go to the very beginning of the cell and try to delete it I must hit the delete key twice to remove one space! But when I go to the first character in the cell and instead hit backspace I only need to press it once.
What else can I do to eliminate this weird non-space whitespace character?
If cell A1 contains non-visible junk characters, you must identify them before you can remove them.
Pick some cell and enter:
=IFERROR(CODE(MID($A$1,ROWS($1:1),1)),"")
and copy down. This will give you the CHAR code for each character in A1
Then you can use SUBSTITUTE() to remove the offender.
Lets assume column A has text where some cells are good and some have text with the weird space like character at the front. So some cells we want to change and some we don't.
1) Create a one column table with one letter in each cell. I decided to go over to the right to column H for the table. So for example cell H1 has A, cell H2 has B and so on.
2) Get the length of the cell we want to edit. I've put this formula in cell B1.
=LEN(A1)
3) Test the cell for the first letter. This gives us which cell to change and which not. I've put this formula in cell C1.
=ISNA(VLOOKUP(LEFT(A1),$H$1:$H$26,1,0))
4) Change (or not depending on step 3) using RIGHT and the result from LEN.
=IF(B1,RIGHT(A1,B1-2),A1)
Notice that I have to subtract 2 spaces and not one? Like I said it was a strange character.
5) Repeat down the column.
If the first legitimate character in your string will be in the set [A-Za-z0-9] then you could use this formula:
=MID(A1,MIN(SEARCH({"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";0;1;2;3;4;5;6;7;8;9},A1&"abcdefghijklmnopqrstuvwxyz1234567890")),99)
where 99 is longer than the longest string might be. If there are other legitimate starting characters, then add them to both the array constant and the string at the end.
If you might need to remove trailing spaces (char(32)), you can enclose the above in a TRIM function.

Notepad++ CSV splitting and removing fields

I have a collection of data in a CSV file and I want to manipulate it in so that I only use some of the values in it. example I have:
1,2,3,4,5,6
asd,sdf,dfg,fgh,ghj,hjk
asd,sdf,dfg,fgh,ghj,hjk
asd,sdf,dfg,fgh,ghj,hjk
asd,sdf,dfg,fgh,ghj,hjk
asd,sdf,dfg,fgh,ghj,hjk
what I want to do is use only use a few fields and possibly in a different order
1,4,3
I know notepad++ can break up values and rearrange them using \1,\2,ect but I don't know how I would do it for this.
Notepad++ isn't really a spreadsheet, which would be your easiest approach for this kind of edit after importing a .CSV. However it does have some limited column editing features which make this workable. Two steps are required, which are outlined below.
1) Line up your text:
a) Highlight all the text.
b) Select the TextFX menu,
c) then the TextFX Edit sub-menu,
d) then the "Line up mulitple lines by (,)"
option.
You will now have all your columns aligned on the commas.
2) Delete an individual column:
a) Ensure no text is highlighted.
b) Hold down the [alt] key while selecting the column you wish to delete with the mouse.
c) Press the delete key to delete what you've highlighted.
The above assumes you have the TextFX plugin installed. If I remember right, this comes as standard but if not, you can easily find it and add it from the Plugin Manager.
Here is an example of selecting an aligned column using the alt key and the mouse, taken from the official Notepad++ site:
http://notepad-plus-plus.org/features/column-mode-editing.html
This regular expression will match 6 groups of 0+ non-comma characters for each line:
^([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)$
You can then replace with your captured groups like so:
\1,\4,\3
RegEx101
Side note:
Someone correct me if I'm wrong. I've been trying to reduce this down to just one repeated capturing group for legibility, but I can't seem to make it work since it only sees this as one capture group:
^([^,]*,?){6}$