Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to change syperlink from single click to double click | Excel Worksheet Functions | |||
double click | Excel Discussion (Misc queries) | |||
Double click | Excel Discussion (Misc queries) | |||
Click on graph bar to execute a double-click in a pivot table cell | Charts and Charting in Excel | |||
Double-click date entry | Excel Programming |