Trying to get date to enter a cell

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

Trying to get the date entered into column B when something is entered into
the ajoining cell in A row, was advised this would work, but it dosent seem
too, any help please
--
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("A:A")) Is Nothing Then Exit
Sub

On Error GoTo Errorline:

Application.EnableEvents = False
With Target
If Len(.Value) > 0 Then
.Offset(, 1) = Format(Now(), "mm/dd/yy")
End If
End With



Thanks in advance for your help....Bob Vance
 
The basic code would be:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target <> "" Then Target.Offset(, -1) = Date
End Sub

It will need some error-checking for simultaneous changes to multiple cells,
etc.
 
Bob,

I just entered this code and it worked fine for me. I can only guess that
you are not loading the code into the correct module, it should go into your
worksheet code module. To get at this, on the appropriate worksheet,
right-click the sheet tab name, and from the menu select 'View Code'. This
takes you into the worksheet code module, and selects the code pane, where
you should enter that code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Funny That because Vasant Script worked perfectly, Thanks for all your help,
works great :)
 
Actually, I'm surprised my code worked because I think I got columns A and B
confused. But hey, whatever works ... <g>
 
Back
Top