![]() |
Inputting Dates Formula?
Is there anyway to input a date in a cell when data first appears in another
cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! |
Inputting Dates Formula?
You may be able to use a macro to enter the time/date so that it doesn't change.
Take a look at JE McGimpsey's site: http://www.mcgimpsey.com/excel/timestamp.html Scott wrote: Is there anyway to input a date in a cell when data first appears in another cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! -- Dave Peterson |
Inputting Dates Formula?
You could use an event macro. Say we want to record in column B the data
when entry is made in column A. Insert the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim A As Range Set A = Range("A:A") If Intersect(A, Target) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu201001 "Scott" wrote: Is there anyway to input a date in a cell when data first appears in another cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! |
Inputting Dates Formula?
Gary,
Yes, this does work. However, how do I change the destination cell for the date to appear on? For instance, what do I do if I want it to display in Column W? How do I edit your code? "Gary''s Student" wrote: You could use an event macro. Say we want to record in column B the data when entry is made in column A. Insert the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim A As Range Set A = Range("A:A") If Intersect(A, Target) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu201001 "Scott" wrote: Is there anyway to input a date in a cell when data first appears in another cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! |
Inputting Dates Formula?
First thanks for trying a macro solution. (many folks have "macrophobia").
To use W instead of B change: Target.Offset(0, 1).Value = Date into: Target.Offset(0, 22).Value = Date You see 1 is for B 2 is for C etc. -- Gary''s Student - gsnu201001 "Scott" wrote: Gary, Yes, this does work. However, how do I change the destination cell for the date to appear on? For instance, what do I do if I want it to display in Column W? How do I edit your code? "Gary''s Student" wrote: You could use an event macro. Say we want to record in column B the data when entry is made in column A. Insert the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim A As Range Set A = Range("A:A") If Intersect(A, Target) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu201001 "Scott" wrote: Is there anyway to input a date in a cell when data first appears in another cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! |
Inputting Dates Formula?
Ok, I figured that out. Actually I figured out how to change that shortly
after I posted my reply. But one more question. What if I wanted to substitute something as the match results? For instance, what happens if I want to display the date in B1 when A1 equals "Complete." Also, if/when A1 changes and does not match or text is deleted, I would want to clear the date in B1. "Gary''s Student" wrote: First thanks for trying a macro solution. (many folks have "macrophobia"). To use W instead of B change: Target.Offset(0, 1).Value = Date into: Target.Offset(0, 22).Value = Date You see 1 is for B 2 is for C etc. -- Gary''s Student - gsnu201001 "Scott" wrote: Gary, Yes, this does work. However, how do I change the destination cell for the date to appear on? For instance, what do I do if I want it to display in Column W? How do I edit your code? "Gary''s Student" wrote: You could use an event macro. Say we want to record in column B the data when entry is made in column A. Insert the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim A As Range Set A = Range("A:A") If Intersect(A, Target) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu201001 "Scott" wrote: Is there anyway to input a date in a cell when data first appears in another cell? For instance, if I entered data in cell A1, is there a way that B1 will record that date, but not change it the next day? Thanks! |
All times are GMT +1. The time now is 10:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com