ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting date in a range (https://www.excelbanter.com/excel-programming/340150-pasting-date-range.html)

SIGE

Pasting date in a range
 
Hi There,

I would like to Paste the Date in a cell when double clicking on it.
In a limited range: like D5:D25

Underneath code does not really do it for some reason...
How can I determine my range here? (eg: D5:D25)

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
'I would like to jump to the cell on the rigth afterwards
End If
End Sub


Peter81[_4_]

Pasting date in a range
 

This worked for the Range D5:D25 for me.

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVa
_
Target As Range, Cancel As Boolean)
' if Column = 4 i.e. "D" & Row is between 5 and 25
If Target.Column = 4 And Target.Row 4 And Target.Row < 26 Then
Target.Value = Format(Now(), "mm-dd-yyyy")
Target.Offset(0, 1).Select
End If
End Su

--
Peter8
-----------------------------------------------------------------------
Peter81's Profile: http://www.excelforum.com/member.php...fo&userid=2535
View this thread: http://www.excelforum.com/showthread.php?threadid=46781



All times are GMT +1. The time now is 07:17 PM.

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