Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calculating chnages in time

Basically, they log the time and date that a website was 'hit'. The report
requires a great deal of formatting before any sense can be made of it. The
following is the format of the data.

Date Time
01-Sep-06 12:46:50
01-Sep-06 12:46:51
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 15:01:47
01-Sep-06 15:01:47
01-Sep-06 15:01:48
01-Sep-06 15:01:48
01-Sep-06 15:02:01
01-Sep-06 15:02:47
01-Sep-06 15:02:47
01-Sep-06 15:02:47

What i am wanting to do (or hope one of you can help me in doing it ) is
create a macro that compares each row as it goes down, deleting any rows
where the time difference is <= 00:03:00 from the last row, or inserting an
empty row where the difference 00:03:00.

So the above data would be formatted to

01-Sep-06 12:46:50
01-Sep-06 12:46:52

01-Sep-06 15:01:47
01-Sep-06 15:02:47

In addition, if the date changes, I need a blank row inserting. Any help
would be very much appreciated.
this is what i have up to now

the code works by calculating a number taken from multiplying the time
column by 1 to get a decimal number

Sub Final2()
Dim Date1 As Double
Dim Date2 As Double
Dim Date3 As Double
Dim x As Integer

Application.Goto Range("C2")
x = 0
Do Until IsEmpty(ActiveCell.Offset(1, 0).Value)
Date1 = ActiveCell.Value
Date2 = ActiveCell.Offset(1, 0)
Date3 = ActiveCell.Offset(-1, 0)

If Date1 - Date3 < 0.002083333 And Date1 - Date2 < 0.002083333 Then
ActiveCell.Offset(1, 0).EntireRow.Delete
x = x + 1
Else
If Date2 - Date3 < 0 Then
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert
End If
ActiveCell.Offset(1, 0).Select
End If
Loop
MsgBox x & " Rows were deleted", vbInformation + vbOKOnly, "Information"
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Calculating chnages in time

Public Sub PreocessData()
Dim iLastRow As Long
Dim i As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = iLastRow - 1 To 2 Step -1
If Cells(i + 1, "B").Value - Cells(i, "B").Value TimeSerial(0,
3, 0) Then
Rows(i + 1).Insert
ElseIf Cells(i + 1, "B").Value - Cells(i, "B").Value <
TimeSerial(0, 3, 0) Then
Rows(i).Delete
End If
Next i

End With

End Sub


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"stevie888" wrote in message
...
Basically, they log the time and date that a website was 'hit'. The report
requires a great deal of formatting before any sense can be made of it.

The
following is the format of the data.

Date Time
01-Sep-06 12:46:50
01-Sep-06 12:46:51
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 12:46:52
01-Sep-06 15:01:47
01-Sep-06 15:01:47
01-Sep-06 15:01:48
01-Sep-06 15:01:48
01-Sep-06 15:02:01
01-Sep-06 15:02:47
01-Sep-06 15:02:47
01-Sep-06 15:02:47

What i am wanting to do (or hope one of you can help me in doing it ) is
create a macro that compares each row as it goes down, deleting any rows
where the time difference is <= 00:03:00 from the last row, or inserting

an
empty row where the difference 00:03:00.

So the above data would be formatted to

01-Sep-06 12:46:50
01-Sep-06 12:46:52

01-Sep-06 15:01:47
01-Sep-06 15:02:47

In addition, if the date changes, I need a blank row inserting. Any help
would be very much appreciated.
this is what i have up to now

the code works by calculating a number taken from multiplying the time
column by 1 to get a decimal number

Sub Final2()
Dim Date1 As Double
Dim Date2 As Double
Dim Date3 As Double
Dim x As Integer

Application.Goto Range("C2")
x = 0
Do Until IsEmpty(ActiveCell.Offset(1, 0).Value)
Date1 = ActiveCell.Value
Date2 = ActiveCell.Offset(1, 0)
Date3 = ActiveCell.Offset(-1, 0)

If Date1 - Date3 < 0.002083333 And Date1 - Date2 < 0.002083333 Then
ActiveCell.Offset(1, 0).EntireRow.Delete
x = x + 1
Else
If Date2 - Date3 < 0 Then
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert
End If
ActiveCell.Offset(1, 0).Select
End If
Loop
MsgBox x & " Rows were deleted", vbInformation + vbOKOnly, "Information"
End Sub




Reply
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
Time Sheet - Calculating Time Differences for Totals Kathy Excel Discussion (Misc queries) 3 January 14th 10 10:04 PM
Calculating Time with Date/Time checking in formula cmatera Excel Worksheet Functions 2 August 11th 08 01:38 PM
Comparing two Excel data ranges for chnages... NWO Excel Discussion (Misc queries) 2 May 2nd 07 08:01 PM
calculating timesheet, time-in/time-out = total hours & minutes, . Steve Lindsay Excel Worksheet Functions 13 November 8th 06 03:45 PM
i changed a document then saved the chnages, is there anything i . RaHeEL HuSsAIn Excel Discussion (Misc queries) 1 February 24th 05 10:42 PM


All times are GMT +1. The time now is 11:38 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"