ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum Of Columns Cannot Exceed One(1) (https://www.excelbanter.com/excel-programming/383040-sum-columns-cannot-exceed-one-1-a.html)

TonyD

Sum Of Columns Cannot Exceed One(1)
 
I have a worksheet that has a section of columns called Outcome. The Outcome
row section cannot exceed one (1). Basically the operator can only choose one
of five cells to enter a value not exceeding one(1). What can I use to
accomplish this? I tried using Data Validation and it only seems to work for
one cell only.

Gary''s Student

Sum Of Columns Cannot Exceed One(1)
 
You can use data validation. Say we only want a single entry in cells A1
thru E1
In cell A1 set data validation to:
Settings Custom Formula is
=COUNT($A$1:$E$1)<2

Then copy A1 to B1 thru E1

Excel will allow only one of the cells to be set.
--
Gary's Student
gsnu200705


"TonyD" wrote:

I have a worksheet that has a section of columns called Outcome. The Outcome
row section cannot exceed one (1). Basically the operator can only choose one
of five cells to enter a value not exceeding one(1). What can I use to
accomplish this? I tried using Data Validation and it only seems to work for
one cell only.


Bob Phillips

Sum Of Columns Cannot Exceed One(1)
 
'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A:E" '<=== change to suit
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
If Target.Count 1 Then
MsgBox "Too many cells"
Target.Cells(1, 1).Select
End If
End If
End Sub


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"TonyD" wrote in message
...
I have a worksheet that has a section of columns called Outcome. The

Outcome
row section cannot exceed one (1). Basically the operator can only choose

one
of five cells to enter a value not exceeding one(1). What can I use to
accomplish this? I tried using Data Validation and it only seems to work

for
one cell only.





All times are GMT +1. The time now is 08:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com