Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2018, 08:37 AM
SavGDK SavGDK is offline Search for last date and first date and subtract to get hours Windows 7 32bit Search for last date and first date and subtract to get hours Office 2010 32bit
Novice
Search for last date and first date and subtract to get hours
 
Join Date: Apr 2016
Location: Savannah Ga
Posts: 20
SavGDK is on a distinguished road
Unhappy Search for last date and first date and subtract to get hours

I have a large data set with multiple occurrences of a value of 505, I need to find the time the value 505 occurred and subtract the dates to get the total time the value 505 occurred.
I also need to do a similar subtraction to get the hours the column labeled PV was equal to or greater than 490, sometimes that occurs one value below the last occurrence of 505 in the SP column. Please see the attached workbook hopefully it will be more clear, the value in green is the dates I would need to subtract to get the hours the system was greater than or equal to 490. I have over 31,000 lines to get through so any help to automate this would be appreciated.



My spreadsheet also shows some formulas I have tried but with no luck.

Thank you,

dan
Attached Files
File Type: xlsx Time Subtraction File.xlsx (20.0 KB, 13 views)
Reply With Quote
  #2  
Old 04-06-2018, 09:27 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Search for last date and first date and subtract to get hours Windows 7 64bit Search for last date and first date and subtract to get hours Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,767
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

So, subtract the end and begin time of a consecutive series of 505 ?
About the PV it is not so clear. Are the values to be used independent of 505 ? Where should the "green zone" stop?
Are you willing to give a different name to each series?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 04-06-2018, 12:42 PM
NoSparks NoSparks is offline Search for last date and first date and subtract to get hours Windows 7 64bit Search for last date and first date and subtract to get hours Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

@ SavGDK

It appears to me there's going to be over 300 results for each of SP and PV, how and where are you wanting those results?
Reply With Quote
  #4  
Old 04-06-2018, 12:53 PM
SavGDK SavGDK is offline Search for last date and first date and subtract to get hours Windows 7 32bit Search for last date and first date and subtract to get hours Office 2010 32bit
Novice
Search for last date and first date and subtract to get hours
 
Join Date: Apr 2016
Location: Savannah Ga
Posts: 20
SavGDK is on a distinguished road
Default

Hello,

Thank you for the reply, you are correct for the first time I need to subtract the end and begin time, at each series beginning with 505.
Regarding the PV column, the values of interest always occur within the same range of the 505 series, the one difference is up to 2 instances after the last 505 value is changed to 250, the PV value could still be above 490, so I would need to subtract that date value from the first date value where the PV was greater than 490.

Hope that clears it up.
Reply With Quote
  #5  
Old 04-06-2018, 12:55 PM
SavGDK SavGDK is offline Search for last date and first date and subtract to get hours Windows 7 32bit Search for last date and first date and subtract to get hours Office 2010 32bit
Novice
Search for last date and first date and subtract to get hours
 
Join Date: Apr 2016
Location: Savannah Ga
Posts: 20
SavGDK is on a distinguished road
Default Posting solutions

Quote:
Originally Posted by NoSparks View Post
@ SavGDK

It appears to me there's going to be over 300 results for each of SP and PV, how and where are you wanting those results?

I have been putting the results in column E at the first occurrence of each 505 series. Right now that seems easiest because I need to capture the first date that the value occurred anyway.

Thank you,

dan
Reply With Quote
  #6  
Old 04-07-2018, 03:28 PM
NoSparks NoSparks is offline Search for last date and first date and subtract to get hours Windows 7 64bit Search for last date and first date and subtract to get hours Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Hello dan

Think you're going to need VBA for this.

If you filter your data for =505 then use something along the lines of the code below
you could calculate everything except your TimeB.

This assumes .areas(1) is just the header row and starts doing its thing at areas(2),
not ideal but maybe it will give you some ideas.
Code:
With filtRng.Columns(2).SpecialCells(xlCellTypeVisible)
    For i = 2 To .Areas.Count
        strAddress = .Areas(i).Address
        ar = Split(Replace(Mid(strAddress, 2), ":", ""), "$")
        TimeA = (ws.Cells(ar(3), "B") - ws.Cells(ar(1), "B")) * 24
        FirstAvg = WorksheetFunction.Average(.Areas(i).Offset(, 1))
        SecondAvg = WorksheetFunction.AverageIf(.Areas(i).Offset(, 1), ">=" & 490)
        '
        'write those variables to the sheet
        'the first 505 row of each area would be  .Areas(i).Rows(1).Row
        '
    Next i
End With
then you'd need to do the same sort of thing filtering for >=490 in column D and get TimeB the same way.
Reply With Quote
  #7  
Old 04-09-2018, 04:34 AM
SavGDK SavGDK is offline Search for last date and first date and subtract to get hours Windows 7 32bit Search for last date and first date and subtract to get hours Office 2010 32bit
Novice
Search for last date and first date and subtract to get hours
 
Join Date: Apr 2016
Location: Savannah Ga
Posts: 20
SavGDK is on a distinguished road
Default Thank you

Thank you all for the help. I have been able to automate this process.

Thanks again.

dan
Reply With Quote
Reply

Tags
date subraction

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
subtract date and time and convert to decimal hours ? DBenz Excel 5 01-26-2017 05:38 AM
Formula for decimal hours from two date time entries DBenz Excel Programming 0 01-15-2015 05:52 AM
Search for date and then apply mutliple search criteria in huge dataset maxtymo Excel 2 12-01-2013 04:52 AM
Formula to subtract one month from due date field in reminder field ghumdinger Outlook 1 10-01-2011 12:09 AM
Search for last date and first date and subtract to get hours Date and time calcs excluding non-working hours mrsatchmo Excel 1 01-26-2011 08:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft