Data Validation Problems In Excel - excel-formula

I'm trying to create a form, but I'm facing some challenges.
Registration Number should start with an R and have max of 13 characters e.g R1234567891234. I was able to use custom data validation =EXACT(LEFT(D5,2), "R-")
to enforce it starting with R but not for character length.
Then I want some cells(J2:M2) to be un-fillable until others(E2:H2) have text in them. But the problem is that (J2:M2) & (E2:H2) already have this formula/variations of this formula
=IF(ISBLANK($I2),"",IF(TODAY()>$I$2+183,"Exam due",""))
in them
I tried using this
=IF(OR(ISBLANK(L2),ISBLANK(F2),ISBLANK(G3),ISBLANK(H4)),"NEY",IF(ISBLANK($I2),"",IF(TODAY()>$I$2+183,"Exam due","")))
But it doesn't work cause (J2:M2) & (E2:H2) have data validations in them that allows the cells to accept only whole numbers.
So how can I retain the numeric data validation for (J2:M2) & (E2:H2) and still have it to be un-fillable if previous cells are still blank?

For the registration number:
=AND(LEFT(D5,1)="R",LEN(D5)<15)
For the data Validation:
=AND(SUMPRODUCT(ISFORMULA(G2:J2)*1)=0,ROUND(SUM(L2:O2),0)=SUM(L2:O2))

Related

Excel Data Validation - Limit Character Type & Length

I am relatively new to excel so apologies for the simple question.
I would like to add data validation to a range of cells in Excel, the cells will be used to collect "Full Names". I would like the cells to only allow: Text Input (All letters in alphabet both lower and upper case) and have a character length of 1-70.
Im aware of the custom forumla in the Data Validation window however im unsure of the correct command. I have also tried using "Text Length" however this still allows the input of numbers and symbols.
Thanks!
Same
=AND(LEN(A1)<=70,ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(1:999),1),"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ&<>"))))
Try this in the Custom section:
=AND(SUMPRODUCT((MID(UPPER(A1),ROW(INDIRECT("1:"&LEN(A1))),1) >="A")*(MID(UPPER(A1),ROW(INDIRECT("1:"&LEN(A1))),1) <="Z"))=LEN(A1),LEN(A1)<=70)
It checks, case insensitive, that all of the entries are in the range [A-Za-z] and that the length is not longer than 70.
If you want to allow spaces in the entry, then you can add that test as shown below:
=AND(SUMPRODUCT((MID(UPPER(A1),ROW(INDIRECT("1:"&LEN(A1))),1) >="A")*(MID(UPPER(A1),ROW(INDIRECT("1:"&LEN(A1))),1) <="Z") + (MID(UPPER(A1),ROW(INDIRECT("1:"&LEN(A1))),1) =" "))=LEN(A1),LEN(A1)<=70)

Data Validation based off multiple criteria

Unable to compile all formulas in single cell to validate the data
Reviewed other post's with similar request but I am still unable to figure out what I am doing wrong trying to string these together
Unique Entry's
=COUNTIF($A$2:$A$3000, A2)<=1
15 Character Max
=A2>15
Does not start with a space
=IF(OR(LEFT(A2,1)=" "),FALSE,TRUE)
No Punctuation
=ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))
Attempted to string these together using =OR but it does not seem to work. Here is what I tried.
=OR(AND(A2>15),AND(COUNTIF($A$2:$A$3000,A2)<=1),AND(IF(OR(LEFT(A2,1)=" "),FALSE,TRUE)),AND(ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))))
Another thing I don't understand and may be my issue is that I need this to check A2:A3000 my formulas do not account for that except for the unique entries but will data validation take that into account or will the formula need to look at all cells? Hope this makes sense.
You would only use AND:
=AND(ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))),LEFT(A2,1)<>" ",LEN(A2)<=15,COUNTIF($A$2:$A$3000, A2)<=1)
Apply it to the whole range but refer to the upper left cell relatively.

Excel Match Function with two Criteria but differing match types

Basically I am trying to improve a spreadsheet that current uses fixed IF functions within IF functions to determine where to find data, then originally used the VLOOKUP function to return the appropriate cable cleat size. Where "Cleat Diameter">"Cable Diameter".
I've been using this for a while, however excel quickly runs out of resources with all the remaining calculations being performed. As a result, I've opted to put all data a single table, and try to use the match function to retrieve the necessary row. Then Simply use the =INDIRECT function to retrieve data from the appropriate column of the associated row.
Unfortunately I believe the issue relates to the fact that I first need to perform at MATCH Type 0 (exact match), followed by a type -1 for the size to identify the next size up that can accommodate a specific cable size.
I've managed a simple lookup on another dataset using (for exact matches):
=MATCH($B3,'Current Raw Data'!A:A,0)+ROW('Current Raw Data'!A:A)-1
However when I attempt the same thing with two types of matches I get errors. The closest I get it using the following array formula, but it does not work unless the data set is arranged so that the contents of Cell C3 is the first occurring item in the dataset in column A:A:
{=MATCH(C3,($B3='Lookup - Cleats'!A:A)*('Lookup - Cleats'!B:B),-1)}
Main sheet:
Dataset Example:
With this array formula (click Ctrl + Shift + Enter together inside formula bar), you should be able to get your results:
=IFERROR(INDEX('Lookup - Cleats'!C$3:C$26,MATCH($B3&$C3,'Lookup - Cleats'!$A$3:$A$26&'Lookup - Cleats'!$B$3:$B$26,0)),"")
I tried my best to use your data setup but maybe miss one or two things that you will need to adjust accordingly. Let me know if this is not working.

Reading an Excel sheet using ADO/ODBC in Delphi 7

I'm trying to read an Excel sheet from an XLS or XLSX file in memory using Delphi 7. When possible I use automation to read the cells one by one, but when Excel is not installed, I revert to using the ADO/ODBC Jet driver.
I connect using either
Provider=Microsoft.Jet.OLEDB.4.0; Data Source=file.xls;Extended Properties="Excel 8.0;Persist Security Info=False;IMEX=1;HDR=No";
Provider=Microsoft.ACE.OLEDB.12.0; Data Source=file.xlsx;Extended Properties="Excel 12.0;Persist Security Info=False;IMEX=1;HDR=No";
My problem then is that when I use the following query:
SELECT * FROM [SheetName$]
the returned results do not contain the empty rows or empty columns, so if the sheet contains such rows or columns, the following cells are shifted and do not end up in their correct position. I need the sheet to be loaded "as is", ie know exactly from what cell position each value comes from.
I tried to read the cells one by one by issuing one query of the form
SELECT F1 FROM `SheetName$A1:A1`
but now the driver returns an error saying "There is data outside the selected region". btw I had to use backticks to enclose the name because using brackets like this [SheetName$A1:A1] gave out a syntax error message.
Is there a way to tell the driver to select the sheet as-is, whithout skipping blanks? Or maybe a way to know from which cell position each value is returned?
For internal policy reasons (I know they are bad but I do not decide these), it is not possible to use a third party library, I really need this to work from standard Delphi 7 components.
I assume that if your data is say in the range B2:D10 for example, you want to include the column A as an empty column? Maybe? Is that correct? If that's the case, then your data set, when you read the sheet (SELECT * FROM [SheetName$]) would also return 1 million rows by 16K columns!
Can you not execute a query like: SELECT * FROM [SheetName$B2:D10] and use the ADO GetRows function to get an array - which will give you the size of the data. Then you can index into the array to get what data you want?
OK, the correct answer is
Use a third party library no matter what your boss says. Do not even
try ODBC/ADO to load arbitrary Excel files, you will hit a wall sooner or later.
It may work for excel files that contain a single data table, but not when you want to cherry pick data in a sheet primarily made for human consumption (ie where a single column contains some cells with introductory text, some with numerical data, some with comments, etc...)
Using IMEX=1 ignores empty lines and empty columns
Using IMEX=0 sometimes no longer ignores empty lines, but now some of the first non empty cells are considered field names instead of data, although HDR=No. Would not work anyway since valules in a column are of mixed types.
Explicitly looping across cells and making a SELECT * FROM [SheetName$A1:A1] works until you reach an empty cell, then you get access violations (see below)
Access violation at address 1B30B3E3 in module 'msexcl40.dll'. Read of address 00000000
I'm too old to want to try and guess the appropriate value to use so it works until someone comes with yet another mix of data in a column. Sorry for having wasted everybody's time.

Prevent comma-separated list of numbers being interpreted as single large value

33266500,332665100,332665200,332665300 was the original value, cell should look like this: 33266500,332665100,332665200,332665300 but what I see as the cell value in excel is 3.32665E+34
So the question is I want to convert it into the original string. I have found format function on google and I used it like these
format(3.32665E+34,"standard")
giving it as 332,6650,033,266,510,000,000,000
How to parse it or get back the orginal string? I belive format is the function in vba.
Excel has a 15 digit precision limit. If the numbers are already shown like this when you access the file, there is no way to get the number back - you have already lost some digits. VBA code and formulas will not help you.
If this is not the case, you can add a single quote ' mark before the number to store it as text. This will ensure Excel does not try to treat it as a number and thus lose precision.
If you want the value kept exactly, store the data as a string, not as a number. The data type you are using simply doesn't have the ability to do what you are asking it to do.
If you're starting with an Excel file that has already been created then you've already lost the information: Excel has tried to understand what it was given and its best guess has turned out to be wrong. All you can do (if you can't get the source data) is go back to the creator of the Excel file and tell them what's wrong.
If you're starting with, say, a text file that you're importing, then the news is much better:
If you're importing manually using the Text Import Wizard, then at "Step 3 of 3" you need to set "Column Data Format" for the problem field to "Text".
If you're using a macro, you'll need to specify a value for the TextFileColumnDataTypes property that does the same thing. The easiest way to get it right is to use the Macro Recorder.
If you want the four values in the string to be separate cells, then again, look at the Text Import Wizard settings: in Step 1 of 3 you need to set "Delimited" data type (usually the default) and in Step 2 make sure that "Comma" is checked.
The value needs to be entered into the cell as a string. You need to make whatever it is that inserts the value preceed the value with a '.

Resources