Prevent Blank Cells with Data Validation - excel

I'm having a seriously hard time with the simplest of Excel data validations: how do you prevent a blank value? The user needs to enter a number into a cell. If the cell has no value, Excel should throw up an error message. I've tried the following:
=COUNTIF($A5:$A27, "")=0
=ISBLANK($A5)
=ISBLANK($A5)=FALSE
and a whole assortment of ridiculous Excel gymnastics, but nothing has worked. The Ignore Blank checkbox is off, too. How hard can this be?
This is in Excel 2016 running on Windows 10. I've tried Google searches ad nauseum with different search keywords. I've tried winging it. I've tried searching on here fora simple formula to solve the problem.

Assuming you also don't want to allow a value of 0 to be entered, you can use the following validation. However, validation only applies when you're entering values into a cell. If you're in edit mode, you won't be able to hit Enter while the cell is blank. But there's nothing to stop you from ignoring the cell entirely or even selecting the cell and clearing it's contents using the Delete key.
There's no way for Excel to force fields to be mandatory and with good reason. If Excel wasn't going to let you do anything while a mandatory cell was empty, you would be stuck if there were two mandatory cells because you could never complete one cell without Excel complaining about the other cell.
You can only force cells to be mandatory when you're also running macros which could display error messages instead of performing the required tasks if the mandatory fields aren't all complete.
As per the comment, the best thing to do is highlight empty mandatory cells using conditional formatting. From the Home tab, create conditional formatting based on value equal to 0 then set the background format to red (or whatever you want).

Related

How do I fix cells in Excel that contain formulas, but are showing as empty cells?

I have tried to find this scenario somewhere but haven't been able to find any useful resources.
Essentially, I have performed some work in Excel and upon returning to the file the row sizes were so large the file could not used properly, and the cells were blank. The row sizes was an easy fix, however the blank cells are strange because they still contain text/formulae.
Has anyone seen this issue before, and know how to fix it?
Thanks!!!!
In this image, you can see that the selected sell contains some text
Here, if I double click to edit the cell contents, there seems to be some kind of disconnect between the location of the cell, and where Excel is allowing me to edit the text
I think you should start working with "formulatext()" Excel function: if you have a formula, this returns a full string
I've seen issues like this in the past and have always first tried the "Text to Columns" Data Tool on the Data Menu. I have used this when cells are unexpectedly blank, or when my dates are registering as dates or formulas are registering as formulas. It might help.

Excel Data Validation list of concrete percentages not working - bug?

I have a cell that needs to hold a user-editable percentage, but it may only contain a multiple of 10% in the range 0%-100%.
My logical solution was to just apply data validation on the cell, and specify it as "List", with the list being "0%,10%,...,100%". This way the users can both type in the number as well as select it from the in-cell drop down list.
However, when I consecutively save & close the workbook and then re-open it again, only the drop down entry works. All attempts to manually enter a percentage lead to Excel disallowing it; it just doesn't recognize the input as valid anymore. Changing the data validation definition a bit and back again makes it all work as expected, but only up to the next re-open of the workbook.
A workaround I found is to specify the valid percentages in a named cell range, and refer to that range in the validation rule; this keeps working even across re-opens of the workbook.
I wonder though if this is truly an Excel 2010 bug, or if it's something particular to my Excel installation? If anyone could test this (especially on other Excel versions), I'd be very grateful.
The steps to reproduce it:
Start a new workbook
Select cell A1 and format it as a percentage
Apply data validation, and
Set 'allow' to "List"
Set 'source' to "0%,10%,20%" (without the quotes)
Keep 'ignore blanks' and 'in-cell dropdown' checked
Verify you can both manually and via the drop-drown list enter one of these choices (you can enter it either as 10% and 0.1)
Save the workbook, close it, and re-open it
Try to enter another percentage, both via the drop-down list and manual entry
Result: manual entry triggers the data validation error prompt...
If this is a genuine bug, I'll post the above mentioned solution as a proper solution. If you have a better one, that is of course welcome as well!
Addition
The workaround I found comes down to:
In the cells C1 to C3 enter the values 0%, 10% and 20% respectively.
Select the range C1 to C3, and name it e.g. "allowedPercentages"
In the data validation for cell A1, set the 'source' to "=allowedPercentages" (without the quotes)

Format another cell based on this cell value

Is it possible based on current cell value, format another cell? Maybe I am overcomplicating things, but what I need to achieve is to display a message in a cell if the file is in Protected Mode. Once a user clicks "Enable Editing" this message should disappear. So what I thought of doing is have a cell set to the message. Then have another cell change this is cell if some calculation is correct. Since it won't be able to calculate until Editing is enabled, the message will display. And once a user Enables Editing, the message will be gone. Is there a direct way to do this or a workaround that will do the trick.
Thank you.
have you tried using an IF formula?
=IF(cell=correct,"","Displayed Message")
You can replace the cell=correct with your condition check that you mentioned in your post.
Leave the next set of quotes blank (so if that condition is met no message will appear)
Change the contents of "Displayed Message" to whatever you want to display if your condition is not correct ie. your sheet is in protected mode.
I found a solution. Still using conditional formatting. I set the value of another cell to a formula (=2+2) and then in my cell check if the value is 4 then change format. Guess could do the same with the IF. Just needed to think from a different angle.

Groovy POI created cells considered blank by other programs until ENTER is manually pressed in cells

Ok this is kind of hard to explain.
I create a cell in my worksheet using JAVA POI
newCell= row.getCell(index)
if (containerCell == null) {
containerCell = row.createCell(index)
}
newCell.setCellType(HSSFCell.CELL_TYPE_STRING)
newCell.setCellValue(strVar)
If i then open the worksheet in EXCEL, I see that the cell value is indeed set. However if I load this into another external program that reads EXCEL sheets, it claims the cell I just set is blank.
NOW, if I go back into excel and do a simple "Hit return" on the cell in question, in the formula bar (even though its not a formula) and try to reload it into the external program, it works fine. Do I need to evaluate a formula on a string?
Thanks
I have no experience with Java, but having to hit enter in a cell is usually indicative of calculation being set to manual. Since you are working with API it may be treating your input from Java as a formula (?).
Open the offending workbook in its broken state, and on the sheet you are having problems with choose [Formulas] tab at top, then [Calculation]>Calculate Sheet.
If this updates the value then I see two options...
See if there is an option to manually calculate the sheet with POI, after the value has been entered.
Alternatively, you can write just a tiny bit of VBA to force calculation on that sheet when workbook is opened. MSDN offers a simple example.
http://msdn.microsoft.com/en-us/library/office/aa223802%28v=office.11%29.aspx
I have had to do this for Excel apps where calculation had to be set to manual to avoid excessive overhead. Just a guess though..
I am not sure why this was happening.. and evaluating the individual cells did not solve it however running evaluteAll() on the entire workbook made it work!

Data Validation in Excel through Cell

I want to set up Data Validation on a cell / row of cells so that the value in that particular cell cannot be changed but all the rest of the sheet can be edited, thus why I am not using read only.
Currently if I enter the value in the cell, go to Data > Data Validation > Custom & enter ""it achieves this (see screenshots http://imgur.com/a/Ggqar)
What I want to do is set this validation via the cell rather than manually as I plan on writing this field entry when create the excel document through my application.
I have done a lot on searching online and found methods for doing countif etc.. but nothing deal with formula entry for the Custom criteria.
Is anyone able to help?
Thanks for the quick reply DanB but it's not exactly what I am trying to achieve. My end goal is that my application can pass a value into the file (Column A Row 1 [If easier for formatting it can go into each row in column A which is populated but not required]) and the file will be saved locally. The user will then be entering details in Column B, C, D, E, etc... on their local machine, saving it and processing the file again. I want the application to check Row 1 Col A for the value and decide on how to process the remainder of the file based on this value (the reading the values in the file works already). Because each time my application generates a file it will be unique I want to try do the Data Validation using a formula in the cell so that I can write it using my application and not have to manually apply settings to the file. Is it possible to do this kind of validation using only formulas in the cell when populating it?
Fastest solution would be to use a Protected sheet, but only protect that Cell.
To do this, select the entire sheet, and choose Format Cells.
On the Protection tab, remove the check from Locked.
Now, select just the cell you want to protect, and lock it using the same method. At this point, your entire sheet, except for the 1 cell should have Locked unchecked.
Now, on the review tab within Excel, choose protect Sheet, and uncheck the option to "Select Locked Cells".
Then, while the sheet is protected(you can password protect that part of it), that cell can't even be selected, yet the entire rest of the sheet can be.

Resources