Entering date depending on another cell being populated

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

I posted this question on the bottom of another thread but I am not sure if
anyone looks at threads that have green tick against them as they look as if
they have already been answered. I have copied the original thread and my
extra question below, could anyone help please?

Many thanks.

Leigh

-----------------------------------------------------------------------------------------------

Sorry to jump on your thread Dayne but I have an additional question in this
theme. Bob, you code is just what I am looking for, but is it possible to
make it repeat itself down the sheet? i.e. enter the date in A3 down to A500
if there is text in B3 to B500?

I am new to VBA and trying to learn from reading as much of this forum as
possible!

Many thanks in anticipation of a simple answer :)

Leigh
 
Just expand the range that Target must match:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Set r = Range("B2:B500")
On Error GoTo ws_exit:
Application.EnableEvents = False
If Intersect(Target, r) Is Nothing Then
Else
Target.Offset(0, -1).Value = Format(Date, "dd mmm yyyy")
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
Leigh,

Is this what you want

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$2" Then
Range("A2:A500").Value = Format(Date, "dd mmm yyyy")
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Thanks Bob and Gary's student. Both of your answers work well for me on
different parts of my workbook. I appreciate you taking the time.

Leigh :0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top