View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Macro to Enter text

We can shorten your function a little bit...

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)
Cancel = True
If InStr("X", ActiveCell.Value) Then _
ActiveCell.Value = Chr(88 - Asc(ActiveCell.Value & Chr(0)))
End Sub

Note: I added Cancel = True in the routine so that edit mode is not
activated in case that option is set.

Rick


"Mark Ivey" wrote in message
...
Try this in ThisWorkbook

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)

If ActiveCell.Value = "X" Then
ActiveCell.Value = ""
ElseIf ActiveCell.Value < "X" Then
If ActiveCell.Value < "" Then
Exit Sub
ElseIf ActiveCell.Value = "" Then
ActiveCell.Value = "X"
End If
Else
End If

End Sub








"rpick60" wrote in message
...
I have a worksheet that users will have to insert X into cells for
items to order.
I would like a function that if the cell is blank then add "X" but if
their is "X" in then remove it to a blank.

It is like a toggle on or off.

Any ideas

Thanks