View Full Version : double click
hi,
when I click a cell I want to see tick symbol when I re-click I want it empty.
When cell has tick, I want a formula to see the value of the cell as number "1", then a formula will be operated
regards
lenze
04-19-2007, 02:06 PM
Perhaps my KB article will help?
http://vbaexpress.com/kb/getarticle.php?kb_id=879
lenze
hi,
can I see the number 1 instead of tick, value of the cell will be 1 as well.
aim is to see 1 in the cell
regards.
mdmackillop
04-19-2007, 02:16 PM
Paste this in the worksheet module
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target = "" Then
Target = 1
Target.NumberFormat = "a;;"
Target.Font.Name = "Marlett"
Else
Target = ""
Target.Font.Name = "arial"
Target.NumberFormat = ""
End If
Cancel = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Target.NumberFormat = ""
End Sub
hi,
compile error
ambigious name detected: worksheet before double click
code in the sheet;
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Selection.Count > 1 Then Exit Sub
If Target = Cells(1, 9) Then
Target.NumberFormat = "dd/mmm/YYYY"
Target.Value = Date
Cancel = True
End If
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Cells(40, 6) = "" Then
Cells(40, 6) = 1
Target.NumberFormat = "a;;"
Target.Font.Name = "Marlett"
Else
Cells(40, 6) = ""
Target.Font.Name = "arial"
Target.NumberFormat = ""
End If
Cancel = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Target.NumberFormat = ""
End Sub
mdmackillop
04-19-2007, 02:31 PM
You can only have one doubleclick event.
hi,
I only want to activate F 40 not ohter cells , tick or empty, but below code does not work .
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Selection.Count > 1 Then Exit Sub
If Target = Cells(1, 9) Then
Target.NumberFormat = "dd/mmm/YYYY"
Target.Value = Date
Cancel = True
End If
If Target = [f40] Then
[f40] = 1
Target.NumberFormat = "a;;"
Target.Font.Name = "Marlett"
If Target = [f40] Then
[f40] = ""
Target.Font.Name = "arial"
Target.NumberFormat = ""
End If
End If
Cancel = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Target.NumberFormat = ""
End Sub
mdmackillop
04-19-2007, 03:38 PM
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Address
Case "$F$40"
SetTick Target
Case "$I$1"
SetDate Target
End Select
Cancel = True
End Sub
Sub SetDate(Target As Range)
Target.NumberFormat = "dd/mmm/YYYY"
Target.Value = Date
End Sub
Sub SetTick(Target As Range)
With Target
If .Value = "" Then
.Value = 1
.NumberFormat = "a;;"
.Font.Name = "Marlett"
Else
.Value = ""
.Font.Name = "arial"
.NumberFormat = ""
End If
End With
End Sub
hi,
thanks for the code. I can use F2 to enter any cell, but I cannot use double click. Do we have to revise the code ?
regards
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Address
Case "$F$40"
SetTick Target
Case "$I$1"
SetDate Target
End Select
Cancel = True
End Sub
Sub SetDate(Target As Range)
Target.NumberFormat = "dd/mmm/YYYY"
Target.Value = Date
End Sub
Sub SetTick(Target As Range)
With Target
If .Value = "" Then
.Value = 1
.NumberFormat = "a;;"
.Font.Name = "Marlett"
Else
.Value = ""
.Font.Name = "arial"
.NumberFormat = ""
End If
End With
End Sub
mdmackillop
04-20-2007, 01:31 PM
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Address
Case "$F$40"
SetTick Target
Cancel = True
Case "$I$1"
SetDate Target
Cancel = True
End Select
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.