PC Review


Reply
Thread Tools Rate Thread

Calculating chnages in time

 
 
=?Utf-8?B?c3RldmllODg4?=
Guest
Posts: n/a
 
      27th Nov 2006
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      27th Nov 2006
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" <(E-Mail Removed)> wrote in message
news:A19D1A25-9A18-4A04-950B-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare and find chnages Prav Microsoft Access VBA Modules 2 5th Jun 2008 12:10 AM
Fix re track chnages bug Word 2000. aalaan Microsoft Word New Users 7 14th Nov 2006 06:46 PM
calculating timesheet, time-in/time-out = total hours & minutes, . =?Utf-8?B?U3RldmUgTGluZHNheQ==?= Microsoft Excel Worksheet Functions 13 8th Nov 2006 03:45 PM
Excel chnages to Ouotlook Himansu Amin Microsoft Excel Discussion 0 31st Mar 2005 10:54 PM
Detecting Chnages in a Control Collection =?Utf-8?B?Sm9lIExveWQ=?= Microsoft C# .NET 3 19th Dec 2003 02:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.