only allow 1 or 2 in a cell range / date

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
test_servey.xlsm
ABCDEFGHIJKL
5WingFloorDeskDockUSB3K/BMouseMonitorHDMI/DVIDVI/DVINote / CommentsDate
61111111Full Kit
72222222No Kit
81211121Part Kit
Site Survey
Cells with Data Validation
CellAllowCriteria
K6:K8List=DropDown!$A$2:$A$4



Good evening,

I have 3 issues:-

1) in the cells that have 1 or a 2, i want to force the user only to use 1 or 2 in the respective area (d6-j999 .and should the user not use 1 or 2 in the respective cells, a popup message will appear stating the fact .
2+3) in the date which MUST be entered when , can the date be triggered so when there is data in the range k6-k999.
I cannot use ()now as it will change the date each each day. So can it be done so the date will automatically enter, but not change when the 'system' date does?

The above is well out of my scope & therefore reaching out to Mr Excel for help.

Thank you for your assistance with my issue.
 
Last edited:
I see, it's supposed to go in here ...

Rich (BB code):
    Const BINARY_RANGE      As String = "d6:J999"
    Const COMMENTS_RANGE    As String = "K6:K999"

    Const PLACEHOLDER       As String = "$@#@$"
    Const MESSAGE           As String = "Cell $@#@$ Only 1 Is Allowed!"
   
    Dim Act As Boolean
    Dim c   As Range
   
    Application.EnableEvents = False
    For Each c In Target
        Act = False
        If Not Application.Intersect(c, Range(BINARY_RANGE)) Is Nothing Then
            If IsError(c.Value) Then
                Act = True
            ElseIf c.Value = vbNullString Then
                ' do nothing
            Else
                If c.Value <> 0 And c.Value <> 1 Then
                    Act = True
                End If
            End If
            If Act Then
                c.Value = vbNullString
                MsgBox Replace(MESSAGE, PLACEHOLDER, c.Address)
            End If
        End If
    Next c
    For Each c In Target
        If Not Application.Intersect(c, Range(COMMENTS_RANGE)) Is Nothing Then
            If IsError(c.Value) Then
                c.Offset(0, 1).Value = vbNullString
            Else
                If Len(c.Value) = 0 Then
                    c.Offset(0, 1).Value = vbNullString
                Else
                    c.Offset(0, 1).Value = Date
                End If
            End If
        End If
    Next c
    Application.EnableEvents = True
thanks .. that works great.

have good day & best wishes too.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,509
Messages
6,125,215
Members
449,215
Latest member
texmansru47

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