I'm looking to try and do two separate types of validation.
Is it possible to configure validation on a cell to check the first character in that cell and it must be a letter ?
Eg. Anything starting with A-Z case insensitive is fine.
Is is possible to set a cell so it can only contain a number ?
I've got the number check working using =ISNUMBER(J1) that seems to only allow numbers.
I'm trying to check the first character and have tried:
=ISTEXT(LEFT(B10,1)) but that doesn't seem to do what I was hoping..
Thanks
Checking if the whole cell is text is easy with just a simple formula, but if you want to check for only the first letter, then it's more involved.
To ensure that the first character is NOT a number, you can use the custom validation formula
=NOT(ISNUMBER(SUM(LEFT(A1,1),0)))
That will still allow special characters llike $ or & etc. as the first character. If you only want to allow a-z and A-Z as the first letter, then use
=AND(CODE(LEFT(A1,1))>=56,CODE(LEFT(A1,1))<=122)
To allow only numbers, use the built in validation options for Decimal or Whole Number.
Select one or more cells to validate.
Open the Data Validation dialog box.
For this, click the Data Validation button on the Data tab, in the Data Tools group or press
the key sequence Alt > D > L (each key is to be pressed separately).
On the Settings tab of the Data Validation dialog window, select Custom in the Allow box, and enter your data validation formula in
the Formula box.
Click OK.
For text only in a cell build a custom rule with the ISTEXT function, for example:
=ISTEXT(D2)
Custom rule for numbers only in a cell using ISNUMBER.
=ISNUMBER(D2)
Reference: https://www.ablebits.com/office-addins-blog/2017/08/17/use-data-validation-excel-custom-rules-formulas/
Related
I'm working on the user enters the value like R11200 or R11.200 in the cells. So if enters the value with dot(full stop or period) like r11.200, the function or formula should remove the dot automatically to R11200 . I'm tried with autocorrect and it doesn't work.
Does anybody give me a solution? Thanks
I'm working on the user enters the value like R11200 or R11.200 in the cells. So if enters the value with dot(full stop or period) like r11.200, the function or formula should remove the dot automatically to R11200 . I'm tried with autocorrect and it doesn't work.
Does anybody give me a solution? Thanks
To automatically remove the dot in the same cell you need VBA programming (Worksheet change event).
But with data validation, you could force the user to put in the data without a dot.
Formula:
=NOT(ISNUMBER(FIND(".";J2)))
Replace semicolon with comma, if your Excel version needs it.
You can create a custom Error message
If you only need to get rid of dot ( . ), you can use SUBSTITUTE formula =SUBSTITUTE(A1,".","")
Output:
Also you can use Data Validation with custom formula to prevent user from entering various symbols:
=ISNUMBER(SUMPRODUCT(SEARCH(MID(A1:A2,ROW(INDIRECT("1:"&LEN(A1:A2))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))
In this case only uppercase letters, lowercase letters and numbers are allowed.
I'm working with a database containing information on MPs. I'm trying to set up a rule that would colour code entries in the "MP name" column, according to party (eg if I enter "Rachel Maskell" into the list, the text would turn red).
I've tried using the "new rule" function but I keep running into character and cell limits. If I try and enter all of the relevant MP names straight into the "format only cells with:" box in the new rule tool I exceed the character limit. If I try and select a column containing all the relevant MP names and use that as my referent I get a error message telling me I've selected too many cells.
Is there a way I can get around this problem?
You can use "Use a formula to determine which cells to format"
Sorry I don't know much about politics
I am struggling with the autocomplete list in my excel document.
I was trying to use the example from OzGrid
https://www.ozgrid.com/Excel/autocomplete-validation.htm
But it seems like this step is not explained well enough.
First of all, I did step one by linking my cells between these 2 sheets.
[![enter image description here][1]][1]
In both "Frontsheet" and "Locality" the list range is from C51 to C67, as per the OzGrid advice.
Next the step with [Dynamic Ranges][2] probably refers to older versions of Excel with traditional menu, where we could select the "Tools" from the bar. Now in Excel 2016 I believe, that it should be like follows:
Formulas - Name manager - New... where we put our name, scope and refers to (range). I have created the Myrange
[![enter image description here][3]][3]
and finally, I put the formula (assuming that the C50 is my dropdown list cell):
=OFFSET(Frontsheet!$C$50,0,0,MATCH("*",Frontsheet!$C$51:$C$67,-1),1)
but I am getting nothing apart of #N/A
I don't know what's next.
I don't want to use VBA this time, because I want to have these lists allocated to the specified cells. I want to search the records by typing not by selecting since I have got them quite a lot. Is it possible?
This question is somewhat a duplicate to the previous ones, which unfortunately didn't bring me the solution.
Excel 2010: how to use autocomplete in validation list
Excel data validation with suggestions/autocomplete
Your formula =OFFSET(Frontsheet!$C$50,0,0,MATCH("*",Frontsheet!$C$51:$C$67,-1),1) shouldn't return anything but #N/A when entered in a cell because it defiens a range which Excel can't display in a single cell. However, you can use it to define a named range and then use that name to define a Data Validation list.
MATCH("*",Frontsheet!$C$51:$C$67,-1) doesn't work reliably if there are numbers in the lookup range. You might replace it with COUNTA(Frontsheet!$C$51:$C$67) which can deal with numbers or text equally well. The difference is that MATCH will produce the entire list, including intervening blanks, while COUNTA will truncate the list at the bottom by as many rows as there are blanks higher up. Either way, one usually avoids blanks in the source for a validation list.
If you want the user to be able to either choose or enter, you must disable Show alert after invalid data is entered on the Error Alert tab of the Data Validation dialog box, where you set up the validation rules.
The OzGrid solution is poorly written and deceptive. It is simply capitalizing on AutoComplete for cell values. There is no magic in linking to another sheet and using offset or in creating a named reference.
All you need to do is add a list of values you intend to use in the column above the column. Avoid empty rows between this list of 'default' values and what you intend to enter.
Skipped rows 'break' AutoComplete for cells.
But can be resolved by adding an adjacent contiguous 'indexing' column.
I need to set data validation on an excel cell to be a specific format. I haven't been able to figure it out myself so far.
The requirements are:
20 characters in length
first 4 characters have to be numeric
characters 5&6 have to be '00'
characters 7-18 need to be alphanumeric
characters 19&20 need to be numeric
Can anyone help me with this?
Use a custom formula like:
=and(Len(A1)=20,isnumber(left(A1,4)+0),mid(A1,5,2)="00",isnumber(right(A1,2)+0))
and make sure to uncheck the Ignore blank option.
Note: this would actually allow any characters for 7-18. If it has to be restricted to A-Z and 0-9 that will require an addition to the formula.
Edit:
Based on the clarified requirements, I would suggest VBA be involved. Add a new module with this function:
Function IsValid(InputText As String) As Boolean
IsValid = UCase$(InputText) Like "####00[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]##"
End Function
Then select the first cell to which you want to apply the data validation - I'll assume A1. Using Name Manager, define a name called IsValidEntry using the formula:
=IsValid(A1)
If your DV cell is not A1, use the appropriate address here but do not include any $ signs.
Now in the DV settings you can choose Custom, uncheck the Ignore Blanks option, and use =IsValidEntry as the source.
Is there a way to add a blank column to a query in Query Studio? I tried to use a calculation on an existing column but the only options that I get are for First Characters, Last Characters, Concatenation, and Remove Trailing Spaces. None of these options allow you to enter a decode, case or IF statement.
Any assistance is greatly appreciated. Thanks.
It's a bit of a hack as Query Studio is really all about making it easy to get data and doing anything with layout is really a job for Report Studio, but you can do the following:
a) create a calculated column on a text field. Select 'Concatenation' as the operation and put a space as the preceding text. Click ok
b1) right-click on the new column and select 'Format', then 'Text' and enter 1 for the number of characters
or
b2) create another calculated column from the first calculated column, set it to 'first characters' and enter 1 for the number of characters. The first calculated column can now be deleted.
Both of these approaches will give a column that only contains a single space - not actually blank but close enough for most purposes. The first approach is a little quicker but may result in the text still existing in some output versions (e.g. csv) - I'd need to do more testing to confirm.
The column title can be edited (to be set to blank) by double clicking it, of course.