PC Review


Reply
Thread Tools Rate Thread

How to create a function that fills the current date in an adjoining cell

 
 
Dave K
Guest
Posts: n/a
 
      26th Jun 2007

Hello, I am trying to create a macro (or perhaps there is a simple
function) that will automatically fill the current date in the left
column (Column A) when I enter any text or data in a cell in Column
B.

So for example, I want cell A4 to read 06/26/07 if I enter anything in
cell B4. And then in two weeks, if I add new info in cell B5, I want
cell A5 to read the date of that entry.

Anyone know of a good formula or macro that would do this?

Thanks in advance for any suggestions you can provide.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      26th Jun 2007
Paste the below code into the Sheet module of interest:
Also, Click Column A's Column Header -- And Format the entire
Column as a Date...

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


"Dave K" wrote:

>
> Hello, I am trying to create a macro (or perhaps there is a simple
> function) that will automatically fill the current date in the left
> column (Column A) when I enter any text or data in a cell in Column
> B.
>
> So for example, I want cell A4 to read 06/26/07 if I enter anything in
> cell B4. And then in two weeks, if I add new info in cell B5, I want
> cell A5 to read the date of that entry.
>
> Anyone know of a good formula or macro that would do this?
>
> Thanks in advance for any suggestions you can provide.
>
>

 
Reply With Quote
 
ssGuru
Guest
Posts: n/a
 
      26th Jun 2007
On Jun 26, 2:00 pm, JMay <J...@discussions.microsoft.com> wrote:
> Paste the below code into the Sheet module of interest:
> Also, Click Column A's Column Header -- And Format the entire
> Column as a Date...
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column = 2 Then
> Target.Offset(, -1).Value = Date
> End If
> End Sub
>
>
>
> "Dave K" wrote:
>
> > Hello, I am trying to create a macro (or perhaps there is a simple
> > function) that will automatically fill the current date in the left
> > column (Column A) when I enter any text or data in a cell in Column
> > B.

>
> > So for example, I want cell A4 to read 06/26/07 if I enter anything in
> > cell B4. And then in two weeks, if I add new info in cell B5, I want
> > cell A5 to read the date of that entry.

>
> > Anyone know of a good formula or macro that would do this?

>
> > Thanks in advance for any suggestions you can provide.- Hide quoted text -

>
> - Show quoted text -


How about referencing more than one field? How would you change the
target and make the offset a fixed or named column?

If Target.Column = 2, Target.Column=3, Target Column=4..... Then

Target.Offset(, -1).Value = Date 'reference named column??

Dennis



 
Reply With Quote
 
=?Utf-8?B?cDQ1Y2Fs?=
Guest
Posts: n/a
 
      27th Jun 2007
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column >= 2 And Target.Column <= 4 Then
Application.EnableEvents = False
Target.Offset(, -Target.Column + 1).Value = Date
Application.EnableEvents = True
End If
End Sub

Anything changed in single cells in in Columns B,C, or D results in a date
in column A. DOn't try pasting ranges more than one column wide though.
You could test for this by changing the IF statement to:
If Target.Column >= 2 And Target.Column <= 4 And Target.Columns.Count = 1 Then


--
p45cal


"ssGuru" wrote:

> On Jun 26, 2:00 pm, JMay <J...@discussions.microsoft.com> wrote:
> > Paste the below code into the Sheet module of interest:
> > Also, Click Column A's Column Header -- And Format the entire
> > Column as a Date...
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Column = 2 Then
> > Target.Offset(, -1).Value = Date
> > End If
> > End Sub
> >
> >
> >
> > "Dave K" wrote:
> >
> > > Hello, I am trying to create a macro (or perhaps there is a simple
> > > function) that will automatically fill the current date in the left
> > > column (Column A) when I enter any text or data in a cell in Column
> > > B.

> >
> > > So for example, I want cell A4 to read 06/26/07 if I enter anything in
> > > cell B4. And then in two weeks, if I add new info in cell B5, I want
> > > cell A5 to read the date of that entry.

> >
> > > Anyone know of a good formula or macro that would do this?

> >
> > > Thanks in advance for any suggestions you can provide.- Hide quoted text -

> >
> > - Show quoted text -

>
> How about referencing more than one field? How would you change the
> target and make the offset a fixed or named column?
>
> If Target.Column = 2, Target.Column=3, Target Column=4..... Then
>
> Target.Offset(, -1).Value = Date 'reference named column??
>
> Dennis
>
>
>
>

 
Reply With Quote
 
Dave K
Guest
Posts: n/a
 
      27th Jun 2007
On Jun 26, 8:20 pm, p45cal <p45...@discussions.microsoft.com> wrote:
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column >= 2 And Target.Column <= 4 Then
> Application.EnableEvents = False
> Target.Offset(, -Target.Column + 1).Value = Date
> Application.EnableEvents = True
> End If
> End Sub
>
> Anything changed in single cells in in Columns B,C, or D results in a date
> in column A. DOn't try pasting ranges more than one column wide though.
> You could test for this by changing the IF statement to:
> If Target.Column >= 2 And Target.Column <= 4 And Target.Columns.Count = 1 Then
>
> --
> p45cal
>
>
>
> "ssGuru" wrote:
> > On Jun 26, 2:00 pm, JMay <J...@discussions.microsoft.com> wrote:
> > > Paste the below code into the Sheet module of interest:
> > > Also, Click Column A's Column Header -- And Format the entire
> > > Column as a Date...

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

>
> > > "Dave K" wrote:

>
> > > > Hello, I am trying tocreatea macro (or perhaps there is a simple
> > > >function) that will automatically fill the current date in the left
> > > > column (Column A) when I enter any text or data in a cell in Column
> > > > B.

>
> > > > So for example, I want cell A4 to read 06/26/07 if I enter anything in
> > > > cell B4. And then in two weeks, if I add new info in cell B5, I want
> > > > cell A5 to read the date of that entry.

>
> > > > Anyone know of a good formula or macro that would do this?

>
> > > > Thanks in advance for any suggestions you can provide.- Hide quoted text -

>
> > > - Show quoted text -

>
> > How about referencing more than one field? How would you change the
> > target and make the offset a fixed or named column?

>
> > If Target.Column = 2, Target.Column=3, Target Column=4..... Then

>
> > Target.Offset(, -1).Value = Date 'reference named column??

>
> > Dennis- Hide quoted text -

>
> - Show quoted text -


Thanks for all replies! Much appreciated.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form that Auto Fills Current Date, but does not show up in Query Shayster Microsoft Access Forms 1 22nd Jun 2009 10:11 PM
automatically date a cell when entering data in adjoining cell =?Utf-8?B?Sm9obiBJbW0=?= Microsoft Excel Programming 1 9th Oct 2006 02:53 PM
WHAT FUNCTION 2 ENTER SO THE CELL TURNS RED AFTER CURRENT DATE =?Utf-8?B?YXdpbGxpYW1z?= Microsoft Excel Worksheet Functions 4 1st Jun 2006 09:40 PM
Click on cell-calendar drops down-click on date-date fills cell. . =?Utf-8?B?R2Vvcmdl?= Microsoft Excel Setup 1 15th Apr 2005 08:22 AM
Function that looks to a table and fills in a sequential blank cell in another table =?Utf-8?B?VGFt?= Microsoft Excel Worksheet Functions 1 6th Dec 2003 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 PM.