ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Static date not working using VBA (https://www.excelbanter.com/excel-worksheet-functions/451171-static-date-not-working-using-vba.html)

Joe Clarke

Static date not working using VBA
 
I am trying to insert a static date into column P (from p7 down) if the adjacent column is populated. I need it to remain blank otherwise and the O column is a select-able drop down list.
the code I'm trying to use is as follows but it wont seem to work.
can anyone please advise

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("O7:O50000")) Is Nothing Then
With Target(1, 2)
.Value = Date
.EntireColumn.Autoit
End With
End If
End Sub

Claus Busch

Static date not working using VBA
 
Hi Joe,

Am Fri, 6 Nov 2015 03:16:52 -0800 (PST) schrieb Joe Clarke:

I am trying to insert a static date into column P (from p7 down) if the adjacent column is populated. I need it to remain blank otherwise and the O column is a select-able drop down list.
the code I'm trying to use is as follows but it wont seem to work.
can anyone please advise


try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("O7:O50000")) Is Nothing _
Or Target.Count 1 Then Exit Sub

With Target.Offset(, 1)
.Value = IIf(Len(Target) 0, Date, "")
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


All times are GMT +1. The time now is 10:23 PM.

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