Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dayne Dillon
 
Posts: n/a
Default Date Creation in Cell

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  
Bob Phillips
 
Posts: n/a
Default

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.worksheet.functions
wurz
 
Posts: n/a
Default Date Creation in Cell

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
How to insert date using a pop up calendar control in a cell i Iain the scout Excel Discussion (Misc queries) 4 December 17th 05 09:10 PM
Making a auto date entered into a cell permanent from a template Muncher Excel Discussion (Misc queries) 2 May 26th 05 11:07 PM
Return a date 6 months from a date in another cell Qaspec Excel Worksheet Functions 1 January 21st 05 05:59 PM
Combined date time cell to separate date & time components Mark Ada Excel Worksheet Functions 1 December 2nd 04 01:04 AM
cell assumes wrong date julie from Seattle Setting up and Configuration of Excel 1 November 30th 04 08:51 PM


All times are GMT +1. The time now is 01:31 AM.

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

About Us

"It's about Microsoft Excel"