Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RJH RJH is offline
external usenet poster
 
Posts: 44
Default Double-click entry

Rob gave me some of the code below. I've modified it to include 2 columns
instead of 1 and a message box. It works just fine but I'm sure there's a
better way to write it then to double up the code. I've tried a few things
with no luck. How would I trim this down?

Thanks!

Bob Howard

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then
If Target.Cells 0 Then GoTo Line1 Else
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
Exit Sub

Line1:
MsgBox "This cell contains a date, choose another cell", vbCritical
Target.Offset(0, 1).Select
End If

If Target.Column = 11 Then
If Target.Cells 0 Then GoTo Line2 Else
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
Exit Sub

Line2:
MsgBox "This cell contains a date, choose another cell", vbCritical
Target.Offset(0, 1).Select
End If

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Double-click entry

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel A
Boolean)
Select Case Target.Column
Case 1, 11
If Target.Cells 0 Then
MsgBox "This cell contains a date, choose another cell", vbCritical
Target.Offset(0, 1).Select
Else
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
End If
End Su

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
RJH RJH is offline
external usenet poster
 
Posts: 44
Default Double-click entry

I thought about the select case function but couldn't construct it and make
it work. I also couldn't get the "If, then, else" statement to work, that's
why I used the 'goto'.
It works geat!
Thanks!

Bob Howard


"mudraker " wrote in message
...
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Select Case Target.Column
Case 1, 11
If Target.Cells 0 Then
MsgBox "This cell contains a date, choose another cell", vbCritical
Target.Offset(0, 1).Select
Else
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
End If
End Sub


---
Message posted from http://www.ExcelForum.com/



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
How to change syperlink from single click to double click syperlinker Excel Worksheet Functions 0 June 13th 08 05:01 PM
double click lmb Excel Discussion (Misc queries) 4 September 6th 07 07:38 PM
Double click Anette Denmark Excel Discussion (Misc queries) 10 February 18th 07 04:24 PM
Click on graph bar to execute a double-click in a pivot table cell [email protected] Charts and Charting in Excel 4 August 3rd 05 01:37 AM
Double-click date entry RJH Excel Programming 2 January 30th 04 04:41 PM


All times are GMT +1. The time now is 01:36 AM.

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

About Us

"It's about Microsoft Excel"