ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto populate a cell (https://www.excelbanter.com/excel-programming/354424-auto-populate-cell.html)

Sam Ricca

Auto populate a cell
 
I can automatically insert the time in the column to the right of one cell
by using Select Case Target Address in the Worksheet Change event by
specifying each individual case.

Is it possible to insert the time in a range of cells that I specify (i.e.
C7:C23) if I enter a date into B7:B23? I can't seem to perform the event
unless I specify the case for each individual target.

Thanks,

Sam



Bob Phillips[_6_]

Auto populate a cell
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B7:B23"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If IsDate(.Value) Then
.Offset(0, 1).Value = Format(Time, "hh:mm:ss")
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sam Ricca" wrote in message
...
I can automatically insert the time in the column to the right of one cell
by using Select Case Target Address in the Worksheet Change event by
specifying each individual case.

Is it possible to insert the time in a range of cells that I specify (i.e.
C7:C23) if I enter a date into B7:B23? I can't seem to perform the event
unless I specify the case for each individual target.

Thanks,

Sam






All times are GMT +1. The time now is 12:21 AM.

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