LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculate time difference and convert


Hello All,

I run the following code on a macro and need help making some changes.
When the macro runs the columns are already se to auto filter.
Column I is created by the macro and names it SLA, time here is given
in total hours.
The macro looks at column E and filters on Medium, high and top, date
and time is on column H if Medium is 120 color background on column I
RED, if High is 72 color background on column I RED, if top is 4
color background on I RED.
I would like to add if Medium is 96 but < 120 color background on I
yellow, if High is 60 but <72 color background on I yellow, if Top is
3 but < 4 color background on I yellow.

The time calculated is given in decimal hours, which can run in the
hundreds, is there a way to convert this back to it's corresponding
date and time?

Also after all the calculations and coloring is done, is it posible to
look at column K and filter by the following keywords TEAM "A", TEAM
"B", TEAM "DBA", and SDSK.
Look at column I and count how many REDs and how many YELLOWS for each
of the above keywords out of the total for each on K column, and put
this count on any columns after Column, which are not used, for
example:

TEAM A - 73 Tickets out of which 23 are in RED AND 15 ARE YELLOW

TEAM B - 52 Tickets out of which 14 are in RED AND 5 ARE YELLOW

TEAM DBA - 12 Tickets out of which 0 are in RED AND 5 ARE YELLOW

TEAM SDSK - 4 Tickets out of which 1 are in RED AND 0 ARE YELLOW

your help is greatly appreciated, following is the code used.

Dim ws1 As Worksheet
Dim r As Long, lastrow As Long

Set ws1 = Worksheets("Currently Open Report")
With ws1

Columns("I").Insert Shift:=xlToRight
Cells(1, "I") = "Deadline SLA"
Columns("I").NumberFormat = "###0.00"

lastrow = .Cells(Rows.Count, "E").End(xlUp).Row

dt2 = CDec(Now())

For r = 2 To lastrow

dt1 = CDec(.Cells(r, "H"))

Select Case UCase(.Cells(r, "E"))

Case Is = "MEDIUM"
TimeDiff = (networkdays(dt1, dt2) + ((dt2 - Int(dt2)) - (dt1 -
Int(dt1)))) * 24
Cells(r, "I") = TimeDiff
If TimeDiff 120 Then
Cells(r, "I").Interior.ColorIndex = 3
End If

Case Is = "HIGH"
TimeDiff = (networkdays(dt1, dt2) + ((dt2 - Int(dt2)) - (dt1 -
Int(dt1)))) * 24
Cells(r, "I") = TimeDiff
If TimeDiff 72 Then
Cells(r, "I").Interior.ColorIndex = 3
End If

Case Is = "TOP"
TimeDiff = (dt2 - dt1) * 24
Cells(r, "I") = TimeDiff
If TimeDiff 4 Then
Cells(r, "I").Interior.ColorIndex = 3
End If
End Select
Next r

End With

End Sub


--
chin_un_len
------------------------------------------------------------------------
chin_un_len's Profile: http://www.excelforum.com/member.php...o&userid=30914
View this thread: http://www.excelforum.com/showthread...hreadid=508812

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate time difference da Excel Discussion (Misc queries) 1 March 15th 10 06:45 PM
Time Format and Calculate difference in time da Excel Discussion (Misc queries) 2 November 7th 09 11:11 AM
how to calculate time difference in hh:mm:ss bobby t Excel Discussion (Misc queries) 6 July 19th 07 02:48 PM
how do i calculate the difference in time? Roze Excel Worksheet Functions 15 September 11th 06 08:36 AM
How do I calculate Time difference from PM to AM JAS123 Excel Discussion (Misc queries) 3 March 12th 05 12:37 PM


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"