Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Check mark in cell when selected 2

Status
Not open for further replies.

MJamison07

Technical User
Dec 13, 2001
54
US
I wrote the following to put a check mark in a cell selected with a mouse.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveCell.Select
ActiveCell = Chr(252)
End Sub

It works, but I encountered some problems:
I am not able to select a whole worksheet, row, or column.

I want to limit it to certain cells in the worksheet.
 


Hi,

No, not ActiveCell!!!!!!!!!
Code:
Private Sub Worksheet_SelectionChange(ByVal [b]Target[/b] As Range)
  with [b]Target[/b]
    if .count > 1 then exit sub  'multiple cells, do not process
    if .row = 1 then exit sub    'many times row 1 is headings
    if .Column = 1 then   'column A only, U tell me ???
       .value = Chr(252)
    end if
  end with
End Sub


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
A starting point (for a single cell in column C):
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C:C")) Is Nothing And Target.Count = 1 Then 
    Target.Value = Chr(252)
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You guys make it look easy.

Sorry I left out important info: I have two ranges where I will use the check box in the cell: C10:C20, E10:E20

THANK YOU THANK YOU!!

MJamison
 
Like this ?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Not Intersect(Target, Range("C10:C20")) Is Nothing _
 Or Not Intersect(Target, Range("E10:E20")) Is Nothing) _
And Target.Count = 1 Then 
    Target.Value = Chr(252)
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  with Target
    if .count > 1 then exit sub  'multiple cells, do not process
    if not intersect(target, Union(range("C10:C20"),range("E10:E20"))) is nothing  then   
       .value = Chr(252)
    end if
  end with
End Sub

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top