check two cells for the same value

Jockster

Board Regular
Joined
Jan 16, 2009
Messages
88
One of the cells on the same row in columns "L" and "M" can have a tick in it (capital 'P', Wingdings 2 font).
Both can't have a tick in them. Shoulda second tick be sdded by a user, can a message appear warning them of the error and remove the last tick that was applied?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
One of the cells on the same row in columns "L" and "M" can have a tick in it (capital 'P', Wingdings 2 font).
Both can't have a tick in them. Shoulda second tick be sdded by a user, can a message appear warning them of the error and remove the last tick that was applied?
Maybe in column N you can put this formula:

=IF(COUNTA(L2:M2)>1,"Too Many Ticks","")
 
Upvote 0
Thanks guys, however, I wanted to avoid the formula or validation route. Ideally, I'd like a message box to relay the error message rather than a formula in a cell.
 
Upvote 0
What is the problem with validation?
The process of validating user entry via VBA is inferior to Excel's Validation feature.
 
Upvote 0
I was thinking that the vba approach would be better because it can remove the rogue value from the cell therefore forcing the user to think about what he/she is doing whereas the validation route will warn them but they can leave the value in the cell.
 
Upvote 0
Excel's Data Validation prevents the entry of the rogue value into the cell. Removal is not needed, since it never is there.
By the way, are you using a Double-Click to un/check the cells, if so, Validation is not triggered and a VB routine like
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Cells.Count = 1 And (.Column = 12 Or .Column = 13) Then
            If 1 < Application.CountIf(.EntireRow.Range("L1:M1"), "P") Then
                Application.EnableEvents = False
                MsgBox "only check one"
                .Value = vbNullString
            End If
        End If
    End With
    Application.EnableEvents = True
End Sub

is required.
 
Last edited:
Upvote 0
Thanks Mike.
Yes, I am using a double click to check the cells and this is where the validation fell down because, although it did warn the user, it left the value in the cell.
Thanks again.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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