ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   placing an "X" in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/222624-placing-x-cell.html)

rwfster

placing an "X" in a cell
 
Is there any way to place an "X" in any cell of my choosiing by clicking on
it or by touching the cell with a stylus from a touch screen tablet?
--
rwfster

Gary''s Student

placing an "X" in a cell
 
How about a double-click??

Insert the following event macro in the worksheet code area:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Target.Value = "X"
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200835


"rwfster" wrote:

Is there any way to place an "X" in any cell of my choosiing by clicking on
it or by touching the cell with a stylus from a touch screen tablet?
--
rwfster


Alojz

placing an "X" in a cell
 
Gary, it works well, yet I consider it a bit dangerous as u cannot make undo
when accidentally double click...

"Gary''s Student" wrote:

How about a double-click??

Insert the following event macro in the worksheet code area:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Target.Value = "X"
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200835


"rwfster" wrote:

Is there any way to place an "X" in any cell of my choosiing by clicking on
it or by touching the cell with a stylus from a touch screen tablet?
--
rwfster


Gary''s Student

placing an "X" in a cell
 
You are correct.
--
Gary''s Student - gsnu200835


"Alojz" wrote:

Gary, it works well, yet I consider it a bit dangerous as u cannot make undo
when accidentally double click...

"Gary''s Student" wrote:

How about a double-click??

Insert the following event macro in the worksheet code area:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Target.Value = "X"
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200835


"rwfster" wrote:

Is there any way to place an "X" in any cell of my choosiing by clicking on
it or by touching the cell with a stylus from a touch screen tablet?
--
rwfster


Greg Wilson

placing an "X" in a cell
 
If the cell range is constant then I'd go with checkboxes from the Forms
toolbar and forget the "X". If the number of cells are many and/or change
then this can become a maintenance nightmare. If so, then this has only one
rectangle to manage:

1. Put a rectangle on the worksheet
2. Adjust its size and position so that it just covers the desired cell range
3. Make it invisible by formatting its fill and line properties to No Fill
and No Line respectively
4. Paste the following code to a standard code module
5. Assign the TogX macro to the rectangle

Private Declare Function GetCursorPos Lib "user32.dll" ( _
ByRef lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type

Sub TogX()
Dim c As Range
Dim cp As POINTAPI
GetCursorPos cp
With ActiveSheet
.Unprotect 'optional
With .Shapes(Application.Caller)
.Visible = False
Set c = ActiveWindow.RangeFromPoint(cp.x, cp.y)
.Visible = True
End With
If c.Value = "X" Then c.Value = "" Else c.Value = "X"
.Protect 'optional
End With
Set c = Nothing
End Sub

Regards
Greg


[email protected]

placing an "X" in a cell
 
On Feb 28, 8:16*pm, rwfster wrote:
Is there any way to place an "X" in any cell of my choosiing by clicking on
it or by touching the cell with a stylus from a touch screen tablet?
--
rwfster


Try this for toggling:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Application.EnableEvents = False
If StrComp(Target.Text, "X", vbTextCompare) = 0 Then
Target.Value = ""
Else
Target.Value = "X"
End If
Application.EnableEvents = True
End Sub


All times are GMT +1. The time now is 12:34 AM.

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