Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default HOW DO I GET AN X IN A CELL IN EXCEL TO COME & GO WHEN CLICKED

i am trying to put a tick box into a spread sheet and have failed miserably,
any info greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default HOW DO I GET AN X IN A CELL IN EXCEL TO COME & GO WHEN CLICKED

One way...

Assume you want the X to appear in cell A1.

On the sheet where you want this to happen:

Select the sheet tab
Right click and select View code
Copy/paste the code below into the window that opens:

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo Finish
If Target.Address = "$A$1" Then
With Target
If .Value = "X" Then
.Value = ""
Else
.Value = "X"
End If
End With
End If
Finish:
Application.EnableEvents = True
End Sub

Close the VB editor and return to Excel: ALT Q
Or, click the top "X" to close the window

Select cell A1 and the "X" will appear
Select any other cell
Select cell A1 again and the "X" will be removed


--
Biff
Microsoft Excel MVP


"carbetboy" wrote in message
...
i am trying to put a tick box into a spread sheet and have failed
miserably,
any info greatly appreciated



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default HOW DO I GET AN X IN A CELL IN EXCEL TO COME & GO WHEN CLICKED

Maybe you can use something like this:

Cells A2:A5 are named: rngChkBxs
and formatted with the Wingdings font.

With the below method, Double-Clicking
on one of the rngChkBxs cells toggles the value
between a checked checkbox and an empty checkbox.

To put the code in the workbook:
Right-click on the sheet tab and select View Code

(That will open the VB Editor to the sheet's code module)

Copy the below code into that sheet module:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("rngChkBxs")) Is Nothing Then
With Target
Select Case Asc(.Value)
Case Is = 254:
'Enter a Check Box
.Value = Chr(168)
Case Else:
'Enter an Empty Box
.Value = Chr(254)
End Select
End With
End If
End Sub

Test the rngChkBxs cells by Dbl-Clicking them.

Is that something you can work with?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"carbetboy" wrote in message
...
i am trying to put a tick box into a spread sheet and have failed
miserably,
any info greatly appreciated





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default HOW DO I GET AN X IN A CELL IN EXCEL TO COME & GO WHEN CLICKED

Darn....the code comments got reversed.

Chr(168) is the empty box
Chr(254) is the checked box.

Since I was editing the code, anyway,
I also tweaked it a bit:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("rngChkBxs")) Is Nothing Then
With Target
Select Case Asc(CStr(.Value) & " ")
Case Is = 254:
'Is a Checked Box, enter an Empty Box
.Value = Chr(168)
Case Else:
'Is anything else, enter an Checked Box
.Value = Chr(254)
End Select
End With
End If
End Sub


Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


"Ron Coderre" wrote in message
...
Maybe you can use something like this:

Cells A2:A5 are named: rngChkBxs
and formatted with the Wingdings font.

With the below method, Double-Clicking
on one of the rngChkBxs cells toggles the value
between a checked checkbox and an empty checkbox.

To put the code in the workbook:
Right-click on the sheet tab and select View Code

(That will open the VB Editor to the sheet's code module)

Copy the below code into that sheet module:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("rngChkBxs")) Is Nothing Then
With Target
Select Case Asc(.Value)
Case Is = 254:
'Enter a Check Box
.Value = Chr(168)
Case Else:
'Enter an Empty Box
.Value = Chr(254)
End Select
End With
End If
End Sub

Test the rngChkBxs cells by Dbl-Clicking them.

Is that something you can work with?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"carbetboy" wrote in message
...
i am trying to put a tick box into a spread sheet and have failed
miserably,
any info greatly appreciated









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ecel - every cell clicked on wants to send email searcher01 Excel Discussion (Misc queries) 0 July 11th 07 06:58 AM
How do I create comment boxes that appear when a cell is clicked? pickpj Excel Worksheet Functions 2 May 10th 07 09:52 PM
unhide rows when cell is clicked lauren_roberts08 New Users to Excel 3 June 14th 06 03:06 AM
unhide rows when cell is clicked lauren_roberts08 Excel Worksheet Functions 2 June 13th 06 08:54 PM
Can I format a cell to fill red when clicked with mouse (Excel)? mike.wilson Excel Worksheet Functions 4 May 2nd 05 08:01 AM


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"