Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to create a function that fills the current date in an adjoining cell


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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default How to create a function that fills the current date in an adjoini

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default How to create a function that fills the current date in an adjoini

On Jun 26, 2:00 pm, JMay 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default How to create a function that fills the current date in an adj

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 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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to create a function that fills the current date in an adj

On Jun 26, 8:20 pm, p45cal 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 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
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
automatically date a cell when entering data in adjoining cell John Imm Excel Programming 1 October 9th 06 02:53 PM
WHAT FUNCTION 2 ENTER SO THE CELL TURNS RED AFTER CURRENT DATE awilliams Excel Worksheet Functions 4 June 1st 06 09:40 PM
Click on cell-calendar drops down-click on date-date fills cell. . George Setting up and Configuration of Excel 1 April 15th 05 08:22 AM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM
How to write macro for entering mm/yy where it fills to current mm/yy Annette[_4_] Excel Programming 1 June 17th 04 07:51 PM


All times are GMT +1. The time now is 09:41 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"