Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Entering date depending on another cell being populated

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



"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

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

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dayne Dillon" <Dayne wrote in message
...
Hi
I am trying to write a formula that will enter the date in field A2 if

there
is text in B2 but the date must be the date when B2 was typed into and not
todays date.any help will be appreciated.
Thanks
Dayne




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Entering date depending on another cell being populated

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)

"wurz" wrote in message
...
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



"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

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

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dayne Dillon" <Dayne wrote in message
...
Hi
I am trying to write a formula that will enter the date in field A2 if

there
is text in B2 but the date must be the date when B2 was typed into and

not
todays date.any help will be appreciated.
Thanks
Dayne






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Entering date depending on another cell being populated

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)


"Bob Phillips" wrote:

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)

"wurz" wrote in message
...
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



"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

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

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dayne Dillon" <Dayne wrote in message
...
Hi
I am trying to write a formula that will enter the date in field A2 if
there
is text in B2 but the date must be the date when B2 was typed into and

not
todays date.any help will be appreciated.
Thanks
Dayne






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Entering date depending on another cell being populated

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
--
Gary's Student


"wurz" wrote:

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



"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

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

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dayne Dillon" <Dayne wrote in message
...
Hi
I am trying to write a formula that will enter the date in field A2 if

there
is text in B2 but the date must be the date when B2 was typed into and not
todays date.any help will be appreciated.
Thanks
Dayne




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
First populated cell in row array/ Last populated cell in row arra Skyscan Excel Worksheet Functions 7 May 29th 08 05:20 PM
auto enter date when another cell populated? zim New Users to Excel 6 March 2nd 07 05:40 PM
Payment cell populated based on date formula TonyD Excel Discussion (Misc queries) 6 January 31st 07 09:55 AM
Auto insert Date & Time when another cell is populated Trixie Excel Discussion (Misc queries) 1 October 2nd 06 03:59 AM
How can i change cell colour depending on month of date in cell? andy75 Excel Discussion (Misc queries) 2 January 6th 06 07:46 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"