not allowing certain value to be entered

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi there
I have a sheet which has many columns. in one column, I have values as below. I just want to create a rule/pop up window etc if user enter A-31 or A-24B then excel will say no you can not enter these values. Any hint/idea would be very much appreciate it. Thank you.


A-33
A-27
A-31
A-23
A-45
A-24B

<tbody>
</tbody>
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
.
This is one method :

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim LastRow As Long
    Dim i As Long
      'LastRow = Range("B" & Rows.Count).End(xlUp).Row
      For i = 2 To 15
        Select Case Range("A" & i)
          Case "A-31"
            MsgBox "A-31 and A-24B are not permitted entries in this range." & vbCrLf & vbCrLf & _
                "Please select a different entry.", vbCritical, "Entry Error !"
                Exit Sub
          Case "A-24B"
            MsgBox "A-31 and A-24B are not permitted entries in this range." & vbCrLf & vbCrLf & _
                "Please select a different entry.", vbCritical, "Entry Error !"          'Case ""
                Exit Sub
        End Select
      Next i
End Sub
 
Upvote 0
Hi,

Select/highlight the first cell in subject column, select down as far as needed.

Use this as Custom DV formula (Change F1 to first cell of your subject column):

=AND(F1<>"A-31",F1<>"A-24B")

You can also add "input message", and/or "error alert" within the DV input box.
 
Upvote 0

Forum statistics

Threads
1,215,826
Messages
6,127,122
Members
449,361
Latest member
VBquery757

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