View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
expect_ed expect_ed is offline
external usenet poster
 
Posts: 53
Default Activate code by clicking in cell

This worked well, for a while.
First I copied your code directly. Works fine.
Then I tried using a named range, since I wanted to limit the feature to
non-adjacent cells. That also worked fine.
Then I wanted to use a check instead of an X, so I changed the line
Target.Value = "X" to
Target.Value = Cells (1,15) and put a checkbox in O1. This also worked fine.

So now I'm ready to try it in my project.
I tried creating a named range with all the needed cells, but there were too
many, so I played around a bit with adding named ranges into one named range,
but got stuck, so I decided to try your code with my modifications on the
named range that is a subset of my total desired range.
This would not work.
To trouble shoot I tried several ideas.
1. The Worksheet code already had commandbutton code. I hought that might
somehow interfere, so I commented that out. No difference.
2. The cells I am using had validation turned on so I could have a dropdown
for the checkbox. I turned that off. Still would not work.
3. Tried using a more limited direct reference range instead of the named
range. No good. Also tried inserting Gary's Stuident code with the Union
(range, range,etc.) somewhere along here.
4. Went back to a direct value of "X" for the Target.Value. Nope
5. Went back to the practice sheet. Not sure what changes I made, if any,
but now that code will not work.
6. In the practice sheet, started over with a fresh paste of your code. no
7. Tried in a fresh tab. Still nothing.
8. Tried a fresh workbook. Cut and paste the code. Still will not work.
Now I'm stumped.
HELP (plese)


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo ErrHandler
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("F14:H26")) Is Nothing Then
Application.EnableEvents = False
If Len(Trim(Target)) = 0 Then
Target.Value = "X"
Else
Target.ClearContents
End If
End if
ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"expect_ed" wrote:

What is the best way to code so that when clicking on one of a few dozen
cells that cell is toggled between blank and an check mark symbol?
I found a post that explains using TargetAddress in the sheet code but I
would need a separate routine for each cell that I want to react this way.
Seems like there might be a better way.
I want to put the check box in the cell rather than using the check box
control becuase I have set up extensive conditional formatting of the cells
based on whether there is a check mark or not.

Thanks in advance for any help.
ed