Using IF to specify which type of cell i want to ignore

custhasno

New Member
Joined
Mar 20, 2017
Messages
9
I am currently working on a spreadsheet to show duration between several date/times displayed as DD/MM/YYYY HH:MM. I need to report on the difference between the Request time of a job versus its completion time. The only issue is, not all jobs have a requested time so i have some cells in that range that show as only DD/MM/YYYY which i want to ignore and instead subtract the time the job was allocated from the completion time in a different row. f the request data only shows a date and no time.

My query is, how can i tell the formula that displayed the difference between allocated and completed times when the requested cell only had a date?
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,761
Assuming A1 is the cell in question and if it doesn't contain a time you wish to refer to A2.
=IF(TIME(HOUR(A1),MINUTE(A1),0),A1,A2)
 

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,968
Office Version
365, 2019, 2016
Platform
Windows
excel stores time as part of a day, e.g. 6am = 6/24(hrs) = .25

so cell with dates only are integers with no decimals thus you can check if Cell A1 is date only if

=A1-int(A1) equals to zero
 

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,968
Office Version
365, 2019, 2016
Platform
Windows
you're welcome
 

custhasno

New Member
Joined
Mar 20, 2017
Messages
9
Assuming A1 is the cell in question and if it doesn't contain a time you wish to refer to A2.
=IF(TIME(HOUR(A1),MINUTE(A1),0),A1,A2)
This worked great thanks. Now I'm looking to do something similar in another column but this time i want to ignore any cells that only have a time HH:MM and no date information and use a different cell instead. Is that possible?

So i have Cells which should read DD/MM/YYYY HH:MM but due to a few issues with our system i occasionally get cells with only the HH:MM. I wish to ignore these cells when they do not have date info in them.
 
Last edited:

custhasno

New Member
Joined
Mar 20, 2017
Messages
9
Thanks, so to create a formula that goes to B1 if A1 does not contain the date info (only time) it would be =IF(TIME(DAY(A1),0),A1,B1) ? Can i chance my arm and ask is there a way to combine these in to one formula. So if A1 contains no date info (only time) it uses B1 and if A1 contains no time info (only the date) it takes C1 instead?
 

Forum statistics

Threads
1,082,167
Messages
5,363,528
Members
400,747
Latest member
monty_gl

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top