View Full Version : Solved: Checkmark in Active Cell
coliervile
03-13-2007, 09:46 AM
Is there a way when you click onto a cell and it becomes active a checkmark or and "X" automatically appears in the cell?
Best regards,
Charlie
coliervile
03-13-2007, 10:13 AM
I'm specifically looking for a range of cell (e.g. A2:B100) that if i activate cell B6 a Checkmark will appear in cell B6 and if click the cell a second time, cell B6 the Checkmark will disappear.
Best regards,
Charlie
lucas
03-13-2007, 10:29 AM
Try this Charlie...not sure if you can use it on 2 columns though. Uses a marlett font.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CheckmarkCells As Range
Set CheckmarkCells = Range("A2:A100")
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, CheckmarkCells) Is Nothing Then
If Target.Font.Name = "Marlett" Then
Target.ClearContents
Target.Font.Name = "Arial"
' Range("G16").Select
Target.Offset(0, 1).Select
Else
Target.Value = "a"
Target.Font.Name = "Marlett"
' Range("G16").Select
Target.Offset(0, 1).Select
End If
End If
End Sub
Bob Phillips
03-13-2007, 10:32 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A2:B100" '<== change to suit
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = "" Then
.Value = "a"
.Font.Name = "Marlett"
Else
.Value = ""
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
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.
lucas
03-13-2007, 10:39 AM
Bob's works but you have to click out of the cell and back before it will change again. Mine selects the cell to the right of it after inserting the checkmark so it's ready to go. If you want to use it on 2 columns
Range("A2:B100")
change this in two places in the code to select a cell 2 cells to the right after you get your checkmark.
Target.Offset(0, 1).Select
to
Target.Offset(0, 2).Select
coliervile
03-13-2007, 10:40 AM
Thanks Lucas for your help. I tried it with two columns changing the range to A2:B100 and it doesn't work. I could do without clicking the cells a second time to delete the Checkmark and just use the delete key to remove the Checkmark. Any ideas???
Regards,
Charlie
lucas
03-13-2007, 11:35 AM
See post #5 and the file attached to this post.
coliervile
03-13-2007, 11:49 AM
Is there a way to combine two or three or more ranges to use the Check mark??? Example A2:B100, E2:F100, H2:H100???
Regards,
Charlie
lucas
03-13-2007, 01:04 PM
see attached
coliervile
03-13-2007, 01:13 PM
Lucas thanks for your help and I will mark this solved.
Regards,
Charlie
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.