Easy One

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

You people have been so much help to me and others on this board. I reall
appreciate all of the good information that is given here

Someone listed how to put check marks in cells by using the righ
click method on the mouse - works great! But the code is for a range of columns

I want to select just 2 columns (column 2 and 14) to put the check mark in
Any ideas

Thanks again - you people are great!
 
Hi
if you may post your existing code it should be quite straight-forward
to restrict it on only some columns :-)
 
Warman,

Are you sure it was right-click? That usually bring up a context menu, so it
was probably double-click, or simply selecting a cell.

Here is some code that does it on a cell selection. It goes in the worksheet
code module.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Target.Column = 2 Or Target.Column = 14 Then
With Target
If .Value = "a" Then
.Value = ""
.Font.Name = "Arial"
Else
.Value = "a"
.Font.Name = "Marlett"
End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Here is the code as it is now

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean

If Target.Column <> 2 Then Exit Su
If Intersect(Target, Me.Range("b:n")) Is Nothing Then Exit Su

On Error GoTo errHandler
Application.EnableEvents = Fals
If IsEmpty(Target) The
Target.Formula = "=char(252)
Target.Font.Name = "Wingdings
Els
Target.ClearContent
End I

Cancel = True 'stop the rightclick men

errHandler
Application.EnableEvents = Tru

End Su
 
Hi
just change the line
If Intersect(Target, Me.Range("b:n")) Is Nothing Then Exit Sub
to
If Intersect(Target, Me.Range("B:B")) Is Nothing and Intersect(Target,
Me.Range("N:N")) is nothing Then Exit Sub
 
Bob

The right click works. It does take away the edit menu but that is OK with me in thi
application. I am now trying to limit this function to certain columns

Thanks
War
 
Try this

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)

If Target.Column = 2 Or Target.Column = 14 Then

On Error GoTo errHandler:
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Formula = "=char(252)"
Target.Font.Name = "Wingdings"
Else
Target.ClearContents
End If

Cancel = True 'stop the rightclick menu
End If

errHandler:
Application.EnableEvents = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
One more way:

If Intersect(Target, Me.Range("b:n")) Is Nothing Then Exit Sub

could change to:

If Intersect(Target, Me.Range("b:b,n:n")) Is Nothing Then Exit Sub

and you have to delete this line:
If Target.Column <> 2 Then Exit Sub
 
Back
Top