View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
[email protected] men@work.com is offline
external usenet poster
 
Posts: 4
Default How to get mutally exlusive cells on mouse click


On Sun, 15 Apr 2007 21:34:01 -0700, Jay
wrote:

Hi men@work -

It looks like you want to enter the value "0" (zero) anytime you click in a
cell in column B. Here is one way to do that. Adjust the "rng" variable and
value as necessary.


Yes, I want zero in B but I also need "1" in C and "2" in D etc. But I
can only have one of those numbers per row i.e.either a "0" or a "1"
or a "2" but only one of those to the exclusion of the others.

I'll play with it but would not at all mind if someone could tie the
code all togetherfor me :-) (Enter number on click and have it be
mutually exclusive)

I am so happy I am getting help, I am a bit frustrated hacking around
on this by myself for all too long.

Thanks, everybody!!!!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set rng = Columns("B")
'Set rng = Range("B2:B35") 'Example of specifying a limited range
If Not Intersect(Target, rng) Is Nothing Then
Cells(Target.Row, rng.Column).Value = 0
End If
End Sub
----
Jay



" wrote:

Wow - thanks for all of your responses!!!

If it is like that in here then I would like to ask you to check out
my (I am sure) clumsy code that lets me click on the particular cell
to put a number in it. There must be a slicker and more portable way
(relative refernces or some code that changes/adappts when I need to
insert rows/columns or other changes)) than I have.

Would you mind looking at a sample - please let it fly, I am wide open
to constructive criticism, insults, praises etc. I am obviously still
pretty new at VBA.

Here's the sample:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("B8").Address Then _
Range("B8").Value = 0


If Target.Address = Range("B9").Address Then _
Range("B9").Value = 0


If Target.Address = Range("B10").Address Then _
Range("B10").Value = 0

etc.etc.etc

goes on for pages (sigh)


End Sub




On Sun, 15 Apr 2007 18:16:44 -0700, wrote:

I am working on a survey

I have a total of 22 questions in 5 groups. Each question can have
only 1 of 5 possible answers. The answers have a value attached such
as:

0-Not At All
1-Somewhat
2-Moderately
3-A Lot
4-Extremely

I have the questions listed down column A. The possible answers are
listed next to each question. For example:

Question in A2: Are you feeling sad?

Answer Text:
0-Not At All in B1
1-Somewhat in C1
2-Moderately in D1
3-A Lot in E1
4-Extremely in F1

When, for example, I click the empty cell C2 I have code which will
put the value "1" visibly into the cell. So I can therefore go click
on the right answers on the whole range of questions and everytime I
click on the "Answer" I get the proper value displayed.

This works great but I would like to take it one step further:

How can I make the "Answer" cells mutally exclusive? Right now it is
possible to click every cell and the corresponding value appears. But
per question only one answer out of the 5 choices is allowed.

How can I do this?