Home

Automatically adding the date/time to a cell when another cell is updated

%3CLINGO-SUB%20id%3D%22lingo-sub-264744%22%20slang%3D%22en-US%22%3EAutomatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-264744%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20spreadsheet%20where%20when%20a%20specific%20cell%20is%20updated%20in%20anyway%2C%20the%20date%2Ftime%20stamp%20automatically%20updates%20in%20the%20cell%20right%20beneath%20the%20cell%20that%20was%20updated.%20I%20only%20need%20to%20have%20a%20one%20to%20one%20relationship%20with%20multiple%20cells.%20IOW%2C%20I%20have%205%20cells%20in%20a%20row%20going%20across.%20When%20any%20one%20of%20the%205%20cells%20is%20updated%2C%20I%20want%20an%20updated%20date%2Ftime%20stamp%20to%20appear%20in%20the%20cell%20directly%20below%20the%20cell%20that%20was%20updated.%20Is%20there%20a%20way%20to%20do%20this%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-264744%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-266442%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-266442%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3EIn%20this%20case%2C%20you%20should%20inject%20the%20Sheet2%20with%20the%20same%20code%20but%20with%20some%20changes%20to%20move%20the%20time%20stamp%20to%20the%20right%20place%20in%20Sheet1!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3BIf%20Not%20Intersect(Target%2C%20Range(%22A1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Sheet1.Range(%22A2%22)%20%3D%20Now%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20above%20example%20for%20the%20Cell%20A1%20in%20Sheet1%20which%20has%20a%20formula%20referred%20to%20cell%20A1%20in%20Sheet2%20(%3DSheet2!A1)%2C%20and%20you%20need%20to%20put%20this%20code%20in%20the%20Sheet2%20code%20module%20NOT%20in%20Sheet1.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20have%20more%20than%20one%20cell%20referred%20to%20Sheet2%20such%20as%20cell%20A1%20and%20B1%20in%20Sheet1%2C%20you%20have%20to%20duplicate%20the%20IF%20statement%20in%20the%20same%20code%20of%20Sheet2%20to%20check%20each%20one%20separately%3A%3C%2FP%3E%3CPRE%3ESub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3BIf%20Not%20Intersect(Target%2C%20Range(%22A1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Sheet1.Range(%22A2%22)%20%3D%20Now%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20If%20Not%20Intersect(Target%2C%20Range(%22B1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Sheet1.Range(%22B2%22)%20%3D%20Now%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-266076%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-266076%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20again.%20You%20have%20been%20a%20huge%20help%20here.%20So%20I%20have%20one%20more%20question%20on%20this.%20The%20macro%20works%20when%20I%20manually%20update%20the%20cell%2C%20the%20date%20plugs%20in%20just%20perfect%20and%20it%20updates%20every%20time%20I%20update%20the%20cell.%20However%2C%20I%20was%20hoping%20that%20this%20would%20also%20work%20if%20the%20cell%20was%20updated%20by%20input%20into%20another%20cell.%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20if%20A1%20has%20data%20and%20A2%20is%20where%20the%20date%20updates%20automatically%2C%20I%20want%20to%20have%20a%20formula%20in%20A1%20that%20says%20%22%3DSheet2%3AA1%22.%20I%20then%20enter%20data%20into%20Sheet2%3AA1%20and%20that%20data%20also%20updates%20in%20A1%20on%20the%20original%20sheet%20but%20the%20date%20does%20not%20update%20in%20this%20case.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20am%20ultimately%20trying%20to%20do%20is%20create%20a%20sheet%20that%20updates%20the%20date%20when%20certain%20fields%20are%20updated%20but%20I%20want%20those%20fields%20to%20be%20updated%20by%20inputs%20from%20another%20sheet.%20I%20hope%20this%20makes%20sense.%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20do%20this%20or%20does%20the%20macro%20only%20run%20if%20the%20cell%20is%20updated%20manually%20on%20that%20sheet%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20appreciate%20any%20help%20you%20can%20provide.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-265466%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-265466%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Joseph%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20no%20function%20in%20VBA%20called%20Today%2C%20the%20VBA%20function%20equivalent%20to%20the%20Worksheet%20function%20%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2FTODAY-function-5EB3078D-A82C-4736-8930-2F51A028FDD9%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EToday%3C%2FA%3E%20is%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2FLanguage%2FReference%2FUser-Interface-Help%2Fdate-function%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDate%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20you%20have%20to%20use%20Date%20instead%20of%20Today%20as%20follows%3A%3C%2FP%3E%3CPRE%3ESub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3BIf%20Not%20Intersect(Target%2C%20Range(%22A1%2CB1%2CC1%2CD1%2CE1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Target.Offset(1%2C%200)%20%3D%20Date%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20you%20apply%20this%20change%2C%20you%20may%20get%20the%20date%20in%20the%20worksheet%20like%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20492px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F55225i42546AEC526CC67E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Date.png%22%20title%3D%22Date.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EWhere%20time%20appears%20as%20zeros!%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%3EIf%20you%20encounter%20it%3C%2FSPAN%3E%3C%2FSPAN%3E%2C%20don't%20worry%2C%20it's%20just%20a%20format%2C%20and%20you%20can%20change%20it%20to%20a%20short%20date%20from%20the%20Home%20tab%20as%20follow%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F55226iB3A4EF143FC9A501%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Short%20Date.png%22%20title%3D%22Short%20Date.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-265440%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-265440%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20simplified%20version.%20One%20more%20question%20for%20you%2C%20I%20tried%20replacing%20%22Now%22%20with%20%22Today%22%20to%20get%20just%20the%20date%20but%20that%20didn't%20work.%20How%20can%20I%20change%20this%20so%20it%20only%20shows%20the%20date%20if%20needed%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-264994%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-264994%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%2C%20but%20%3CSPAN%20class%3D%22%22%3EI%20have%20discovered%20a%20simplified%20version%20of%20the%20code%20as%20follows%3A%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%3ESub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3BIf%20Not%20Intersect(Target%2C%20Range(%22A1%2CB1%2CC1%2CD1%2CE1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Target.Offset(1%2C%200)%20%3D%20Now%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20the%20same%20as%20the%20previous%20one%2C%20so%20I%20recommend%20you%20to%20use%20it%20instead.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-264919%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-264919%22%20slang%3D%22en-US%22%3E%3CP%3EHaytham%20-%20Thank%20you%20so%20much%20for%20the%20quick%20response%20on%20this.%20This%20works%20perfectly%20and%20I%20can%20see%20that%20changing%20the%20target%20offset%20allows%20me%20to%20change%20the%20location%20of%20the%20timestamp.%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20great%20and%20exactly%20what%20I%20needed.%20I%20really%20appreciate%20the%20help.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-264757%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-264757%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Joseph%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20possible%2C%20but%20you%20definitely%20need%20to%20a%20VBA%20code%20to%20do%20it!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3ELet's%20say%20the%20five%20cells%20you%20want%20to%20target%20are%20from%20cell%20A1%20to%20E1%3C%2FSPAN%3E%3C%2FSPAN%3E%2C%20so%20please%20hover%20the%20Mouse%20over%20the%20Worksheet%20tab%2C%20right-click%2C%20and%20select%20%3CSTRONG%3EView%20Code%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20copy%20and%20paste%20this%20code%20into%20the%20worksheet%20code%20module%3A%3C%2FP%3E%3CPRE%3ESub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3BIf%20Not%20Intersect(Target%2C%20Range(%22A1%22))%20Is%20Nothing%20Or%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Not%20Intersect(Target%2C%20Range(%22B1%22))%20Is%20Nothing%20Or%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Not%20Intersect(Target%2C%20Range(%22C1%22))%20Is%20Nothing%20Or%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Not%20Intersect(Target%2C%20Range(%22D1%22))%20Is%20Nothing%20Or%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Not%20Intersect(Target%2C%20Range(%22E1%22))%20Is%20Nothing%20Then%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Target.Offset(1%2C%200)%20%3D%20Now%3CBR%20%2F%3E%26nbsp%3BEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20that%2C%20save%20the%20workbook%20as%20.xlsm%20file%20extension%20to%20keep%20the%20code%20saved%20in%20it.%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20apply%20it%20to%20different%20cells%2C%20simply%2C%20you%20can%20change%20the%20cell%20ranges%20in%20the%20code%20and%20%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%20class%3D%22%22%3Etheir%20order%20in%20the%20code%20does%20not%20matter!%3C%2FSPAN%3E%3C%2FSPAN%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-468296%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-468296%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3B%20Hi%26nbsp%3B%20I%20too%20am%20looking%20to%20have%20the%20date%20updated%20in%20a%20cell%20when%20the%20designated%20cell%20is%20changed%26nbsp%3B%20I%20placed%20the%20VBA%20code%20in%20the%20sheet%20code%20tab%20but%20what%20do%20I%20do%20on%20the%20sheet%20itself%3F%20Any%20help%20is%20greatly%20appreciated%20thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-475906%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-475906%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F322785%22%20target%3D%22_blank%22%3E%40Richard4591%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20you%20need%20to%20change%20the%20cell%20references%20in%20the%20code%20to%20comply%20with%20existing%20data%20in%20your%20spreadsheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-476049%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20adding%20the%20date%2Ftime%20to%20a%20cell%20when%20another%20cell%20is%20updated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-476049%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3EThanks%20Haytham%2C%20ill%20give%20that%20a%20try%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Joseph Huisman
New Contributor

I am trying to create a spreadsheet where when a specific cell is updated in anyway, the date/time stamp automatically updates in the cell right beneath the cell that was updated. I only need to have a one to one relationship with multiple cells. IOW, I have 5 cells in a row going across. When any one of the 5 cells is updated, I want an updated date/time stamp to appear in the cell directly below the cell that was updated. Is there a way to do this? 

10 Replies

Hi Joseph,

 

This is possible, but you definitely need to a VBA code to do it!

 

Let's say the five cells you want to target are from cell A1 to E1, so please hover the Mouse over the Worksheet tab, right-click, and select View Code.

 

Then copy and paste this code into the worksheet code module:

Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Range("A1")) Is Nothing Or _
    Not Intersect(Target, Range("B1")) Is Nothing Or _
    Not Intersect(Target, Range("C1")) Is Nothing Or _
    Not Intersect(Target, Range("D1")) Is Nothing Or _
    Not Intersect(Target, Range("E1")) Is Nothing Then

    Target.Offset(1, 0) = Now
 End If

End Sub

 

After that, save the workbook as .xlsm file extension to keep the code saved in it.

If you want to apply it to different cells, simply, you can change the cell ranges in the code and their order in the code does not matter!.

 

Hope that helps

Haytham - Thank you so much for the quick response on this. This works perfectly and I can see that changing the target offset allows me to change the location of the timestamp. 

This is great and exactly what I needed. I really appreciate the help. 

 

Thank you, but I have discovered a simplified version of the code as follows:

Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Range("A1,B1,C1,D1,E1")) Is Nothing Then
    Target.Offset(1, 0) = Now
 End If

End Sub

 

It works the same as the previous one, so I recommend you to use it instead.

 

Regards

Thanks for the simplified version. One more question for you, I tried replacing "Now" with "Today" to get just the date but that didn't work. How can I change this so it only shows the date if needed? 

Hi Joseph,

 

There is no function in VBA called Today, the VBA function equivalent to the Worksheet function Today is Date.

 

So you have to use Date instead of Today as follows:

Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Range("A1,B1,C1,D1,E1")) Is Nothing Then
    Target.Offset(1, 0) = Date
 End If

End Sub

 

After you apply this change, you may get the date in the worksheet like this:

Date.pngWhere time appears as zeros!

 

If you encounter it, don't worry, it's just a format, and you can change it to a short date from the Home tab as follow:

Short Date.png

 

 

Hope that helps

Thanks again. You have been a huge help here. So I have one more question on this. The macro works when I manually update the cell, the date plugs in just perfect and it updates every time I update the cell. However, I was hoping that this would also work if the cell was updated by input into another cell. 

For example, if A1 has data and A2 is where the date updates automatically, I want to have a formula in A1 that says "=Sheet2:A1". I then enter data into Sheet2:A1 and that data also updates in A1 on the original sheet but the date does not update in this case. 

 

What I am ultimately trying to do is create a sheet that updates the date when certain fields are updated but I want those fields to be updated by inputs from another sheet. I hope this makes sense. 

Is there a way to do this or does the macro only run if the cell is updated manually on that sheet? 

 

I appreciate any help you can provide. 

Hi,

 

In this case, you should inject the Sheet2 with the same code but with some changes to move the time stamp to the right place in Sheet1!

 

Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Range("A1")) Is Nothing Then
    Sheet1.Range("A2") = Now
 End If

End Sub

 

The above example for the Cell A1 in Sheet1 which has a formula referred to cell A1 in Sheet2 (=Sheet2!A1), and you need to put this code in the Sheet2 code module NOT in Sheet1.

 

If you have more than one cell referred to Sheet2 such as cell A1 and B1 in Sheet1, you have to duplicate the IF statement in the same code of Sheet2 to check each one separately:

Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Range("A1")) Is Nothing Then
    Sheet1.Range("A2") = Now
 End If
 
  If Not Intersect(Target, Range("B1")) Is Nothing Then
    Sheet1.Range("B2") = Now
 End If

End Sub

 

@Haytham Amairah  Hi  I too am looking to have the date updated in a cell when the designated cell is changed  I placed the VBA code in the sheet code tab but what do I do on the sheet itself? Any help is greatly appreciated thanks

Highlighted

Hi @Deleted,

 

I think you need to change the cell references in the code to comply with existing data in your spreadsheet.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies