Change cell value between EMPTY and X when i click on the cell.

L

Luc

Hello,

How can i change the cell value between empty and X when i click on the
cell.
This is for the cells in column B of all the visible sheets.

Can you provide some code please.....

Thanxxxx,

Luc
 
M

Mike

Paste this code into all visable sheets and change the range of B1:B10 to
your needs
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
Target.Value = "X"
End If
End Sub
 
G

Gord Dibben

No need to paste Mike's code into all worksheets.

Paste this code once into Thisworkbook module.

Private Sub Workbook_SheetSelectionChange _
(ByVal Sh As Object, ByVal Target As Range)
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
Target.Value = "X"
End If
End Sub

Covers all sheets.


Gord Dibben MS Excel MVP
 
L

Luc

Thanks guys,

But i also want to change the cell to Empty if the value is "X"
and change to "X" if it is empty (a kind of toggle)

Luc
 
R

Rick Rothstein

Try it this way then...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top