SOLVED

IF Statement Concerns

%3CLINGO-SUB%20id%3D%22lingo-sub-186091%22%20slang%3D%22en-US%22%3EIF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186091%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20get%20the%20date%2Ftime%20that%20a%20cell%20changes%20but%20not%20have%20it%20autoupdate....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20this%3A%26nbsp%3B%3DIF(B2%20%26lt%3B%26gt%3B%20%22%22%2CNOW()%2C%22Not%20Checked%20Out%22)%20works%20until%20you%20update%20the%20next%20row%20an%20hour%20later%20then%20everything%20changes%20to%20the%20current%20NOW%20date%2Ftime.%20I%20can't%20use%20%22TODAY%22%20because%20it%20doesn't%20give%20me%20the%20time.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-186091%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20%26amp%3B%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186501%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186501%22%20slang%3D%22en-US%22%3EWell%20done%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186433%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186433%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20all%2C%20I%20ended%20up%20using%20the%20VB%20Script%20as%20that%20was%20the%20only%20way%20to%20ensure%20that%20the%20dates%20and%20times%20didn't%20change%20if%20someone%20accidentally%20clicked%20to%20calculate%20the%20sheet.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186341%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186341%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20are%20right%2C%20but%20as%20per%20present%20scenario%20the%20user%26nbsp%3Bis%20getting%20the%20exact%20output%20without%26nbsp%3Bneed%20of%20having%20knowledge%20of%20advance%20excel.%20let%20her%20go%20through%20the%20solution%20and%26nbsp%3Bwait%20for%20the%20response.%20we%20are%20here%20to%20guide.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186201%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186201%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F130464%22%20target%3D%22_blank%22%3E%40Gourab%20Dasgupta%3C%2FA%3E%26nbsp%3BYes%2C%20this%20is%20possible%2C%20but%20it%20can%20have%20implications%20for%20other%20aspects%20of%20the%20workbook%2C%20where%20iterative%20calculation%20is%20not%20desired.%20Unless%20the%20user%20is%20absolutely%20sure%20what%20they%20are%20doing%20with%20this%20setting%2C%20I%20suggest%20avoiding%20this%20approach.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186196%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186196%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jennifer%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20you%20go%3A%3C%2FP%3E%3CP%3E1.%20open%20excel%3C%2FP%3E%3CP%3E2.%20go%20to%3A%20%3CSTRONG%3EFile%20%3C%2FSTRONG%3E%26gt%3B%20%3CSTRONG%3EOptions%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E3.%20in%20popup%20window%20go%20to%20%3A%26nbsp%3B%3CSTRONG%3EFormulas%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E4.%20Check%20%3CSTRONG%3E%22Enable%20iterative%20calculation%22%3C%2FSTRONG%3E%26nbsp%3B%3C%2FP%3E%3CP%3E5.%20Change%20the%20value%20of%20%3CSTRONG%3E%22Maximum%26nbsp%3Biterations%3A%22%20%3C%2FSTRONG%3Efrom%3CSTRONG%3E%20100%20to%201%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E6.%20click%3CSTRONG%3E%20OK%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20suppose%20you%20have%20to%20enter%20the%20value%20A1%20and%20get%20the%20output%20(Time)%20in%20B1%20enter%20the%20following%26nbsp%3Bformula%20in%20B1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3DIF(A1%26lt%3B%26gt%3B%22%22%2CIF(B1%3D%22%22%2CNOW()%2CB1)%2C%22%22)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-186187%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Concerns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-186187%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ewhat%20you%20want%20to%20achieve%20cannot%20be%20done%20with%20the%20NOW()%20formula.%20It%20will%20always%20update%20to%20the%20current%20date%20and%20time.%20If%20you%20want%20a%20time%20stamp%20that%20does%20not%20change%2C%20then%20you%20will%20need%20to%20use%20VBA.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20code%20will%20put%20a%20time%20stamp%20into%20column%20B%20when%20a%20cell%20in%20column%20A%20is%20changed%20by%20the%20user.%20Copy%20the%20code%2C%20then%20right-click%20the%20Sheet%2C%20select%20%22View%20code%22%20and%20paste%20the%20code%20into%20the%20code%20window.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0AIf%20Not%20Intersect(Target%2C%20Range(%22A%3AA%22))%20Is%20Nothing%20Then%0A%20%20%20%20Target.Offset(0%2C%201)%20%3D%20Now%0AEnd%20If%0AEnd%20Sub%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561728%22%20slang%3D%22en-US%22%3ETime%20Date%20Stamp%20Code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561728%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7724%22%20target%3D%22_blank%22%3E%40Ingeborg%20Hawighorst%3C%2FA%3E%26nbsp%3B.%20This%20little%20piece%20of%20code%20solved%20a%20perplexing%20problem%20for%20me.%20A%20next%20step%20is%20to%20save%20the%20workbook%20as%20a%20macro-enabled%20workbook%20(.xlsm).%20I%20did%20not%20do%20that%20and%20when%20I%20reopened%20the%20file%2C%20code%20was%20gone.%20Luckily%20I%20found%20it%20again%2C%20along%20with%20a%20post%20with%20the%20save%20info.%20I%20backed%20up%20the%20code%20to%20a%20text%20file%20for%20safe%20keeping.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1569491%22%20slang%3D%22en-US%22%3ERe%3A%20Time%20Date%20Stamp%20Code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1569491%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F747377%22%20target%3D%22_blank%22%3E%40PCDavis61618%3C%2FA%3E%26nbsp%3B%26nbsp%3BWhen%20you%20write%20VBA%20code%20in%20Excel%20that%20does%20not%20yet%20have%20any%20code%2C%20and%20then%20save%20the%20file%2C%20you%20will%20see%20a%20big%2C%20fat%20warning%20that%20VBA%20code%20can%20only%20be%20saved%20in%20macro-enabled%20files%20and%20you%20are%20prompted%20to%20save%20the%20file%20as%20a%20macro-enabled%20file.%20If%20you%20just%20ignore%20that%20warning%2C%20your%20code%20will%20be%20lost%2C%20of%20course.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExcel%20has%20done%20its%20part.%20Now%20it's%20up%20to%20you%20to%20do%20yours.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I am trying to get the date/time that a cell changes but not have it autoupdate....

 

Using this: =IF(B2 <> "",NOW(),"Not Checked Out") works until you update the next row an hour later then everything changes to the current NOW date/time. I can't use "TODAY" because it doesn't give me the time. 

8 Replies
Best Response confirmed by Jennifer Clark (Occasional Contributor)
Solution

Hello,

 

what you want to achieve cannot be done with the NOW() formula. It will always update to the current date and time. If you want a time stamp that does not change, then you will need to use VBA. 

 

This code will put a time stamp into column B when a cell in column A is changed by the user. Copy the code, then right-click the Sheet, select "View code" and paste the code into the code window.

 

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
    Target.Offset(0, 1) = Now
End If
End Sub

 

Hi Jennifer

 

Here you go:

1. open excel

2. go to: File > Options

3. in popup window go to : Formulas

4. Check "Enable iterative calculation" 

5. Change the value of "Maximum iterations:" from 100 to 1

6. click OK

 

Now suppose you have to enter the value A1 and get the output (Time) in B1 enter the following formula in B1

 

=IF(A1<>"",IF(B1="",NOW(),B1),"")

 

@Gourab Dasgupta Yes, this is possible, but it can have implications for other aspects of the workbook, where iterative calculation is not desired. Unless the user is absolutely sure what they are doing with this setting, I suggest avoiding this approach. 

Hi

 

You are right, but as per present scenario the user is getting the exact output without need of having knowledge of advance excel. let her go through the solution and wait for the response. we are here to guide.

Thank you all, I ended up using the VB Script as that was the only way to ensure that the dates and times didn't change if someone accidentally clicked to calculate the sheet. 

Well done

Thank you @Ingeborg Hawighorst . This little piece of code solved a perplexing problem for me. A next step is to save the workbook as a macro-enabled workbook (.xlsm). I did not do that and when I reopened the file, code was gone. Luckily I found it again, along with a post with the save info. I backed up the code to a text file for safe keeping.

@PCDavis61618  When you write VBA code in Excel that does not yet have any code, and then save the file, you will see a big, fat warning that VBA code can only be saved in macro-enabled files and you are prompted to save the file as a macro-enabled file. If you just ignore that warning, your code will be lost, of course. 

 

Excel has done its part. Now it's up to you to do yours.