data validation

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
Good morning

I have a cell which requires a user to put an entry of between 0 and 1 million
so I used the validation
Allow: Whole Number
Data: Between
Minimum: 0
Maximum: 1000000

Ignore Blank: Unchecked

I have a message which tells the user the acceptable range in case they try to enter a non numeric or numbers outside of this range.

However! Blanks are being accepted can this validation enforce a number between 0 and 1 million,rather than allowing blanks, the error works if a letter, negative, decimal or exceeds 1 million
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Data validation only validates data entry, not the lack of an entry.
 
Upvote 0
Awesome - that is the lateral thinking I was missing :oops:

How stupid do I feel right now
Thanks for not taking the .............
 
Upvote 0
:) no problem.

You'd have to do something like use a BeforeSave event if you need to validate before saving.
 
Upvote 0
:) no problem.

You'd have to do something like use a BeforeSave event if you need to validate before saving.

I tried this but I'm obviously missing something
it is supposed to be checking the value of 5 (merged) cells
and replacing the value with 0 if found to be blank. The idea is it runs the vba when changing the cell, the sheet will open with values in it

Code:
<code>Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$19:$F$19" Then
    If Range("D19").Value = "" Then
        Range("D19").Value = 0
ElseIf Target.Address = "$H$19:$J$19" Then
    If Range("H19").Value = "" Then
        Range("H19").Value = 0
ElseIf Target.Address = "$L$19:$N$19" Then
    If Range("L19").Value = "" Then
        Range("L19").Value = 0
ElseIf Target.Address = "$P$19:$R$19" Then
    If Range("P19").Value = "" Then
        Range("P19").Value = 0
ElseIf Target.Address = "$T$19:$V$19" Then
    If Range("T19").Value = "" Then
        Range("T19").Value = 0
End If
End Sub</code>
 
Upvote 0
:) no problem.

You'd have to do something like use a BeforeSave event if you need to validate before saving.

I did this
it is supposed to be checking the value of 5 (merged) cells
and replacing the value with 0 if found to be blank. The idea is it runs the vba when changing the cell, the sheet will open with values in it

Code:
<code>Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$19:$F$19" Then
    If Range("D19").Value = "" Then Range("D19").Value = 0
ElseIf Target.Address = "$H$19:$J$19" Then
    If Range("H19").Value = "" Then Range("H19").Value = 0
ElseIf Target.Address = "$L$19:$N$19" Then
    If Range("L19").Value = "" Then Range("L19").Value = 0
ElseIf Target.Address = "$T$19:$V$19" Then
    If Range("T19").Value = "" Then Range("T19").Value = 0
End If
End Sub</code>
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top