ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Worksheet_SelectionChange not working (https://www.excelbanter.com/new-users-excel/4636-worksheet_selectionchange-not-working.html)

Bo Rasmussen

Worksheet_SelectionChange not working
 
Hi,

Being relatively new to Excel, I've tried to implement some stuff for
setting a checkmark in cells when clicked.
I've found a solution for this at
http://www.mrexcel.com/archive2/1900/2145.htm which gives me the code found
below. The problem is that nomatter what I do it seems that the
Worksheet_SelectionChange is never called??? Could somebody give me a clue.

Option Compare Text
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:B20")) Is Nothing Then
If Target = "a" Then
Target = vbNullString
End
End If

If Target = vbNullString Then
Target.Font.Name = "Marlett"
Target = "a"
End If
End If

End Sub



Regards
Bo Rasmussen



Harald Staff

Dav Bo

Where did you place the code ? It must be in the right worksheet module or
it won't run. Rightclick the sheet tab of the worksheet, choose "view code"
and there it should be. If not paste it in there.

HTH. Best wishes Harald

"Bo Rasmussen" skrev i melding
...
Hi,

Being relatively new to Excel, I've tried to implement some stuff for
setting a checkmark in cells when clicked.
I've found a solution for this at
http://www.mrexcel.com/archive2/1900/2145.htm which gives me the code

found
below. The problem is that nomatter what I do it seems that the
Worksheet_SelectionChange is never called??? Could somebody give me a

clue.

Option Compare Text
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:B20")) Is Nothing Then
If Target = "a" Then
Target = vbNullString
End
End If

If Target = vbNullString Then
Target.Font.Name = "Marlett"
Target = "a"
End If
End If

End Sub



Regards
Bo Rasmussen






All times are GMT +1. The time now is 04:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com