Hi,
I have imported a huge file(35 MB log file). This file contains a column called "Seconds" which contain data for each seconds starting from 1.
Initial Time and date is also given in the report.
Now what i am trying to do is to insert another column in this sheet called "Start Time". Then for each value corresponding to "Seconds" column, i am adding it to Initial Time given in the report. This value along with date is then displayed "Start Time" column. The subroutine for this is:
Now its giving me an error at following code when "TotalSecon ds" value reaches to 32768. As you can see, TotalSeconds is defined as Long. Still its giving Overflow error.
Can someone help me to resolve this issue.
at
Thanks
Prashant
I have imported a huge file(35 MB log file). This file contains a column called "Seconds" which contain data for each seconds starting from 1.
Initial Time and date is also given in the report.
Now what i am trying to do is to insert another column in this sheet called "Start Time". Then for each value corresponding to "Seconds" column, i am adding it to Initial Time given in the report. This value along with date is then displayed "Start Time" column. The subroutine for this is:
Code:
Sub InsertStartTimeWithDateColumn(QCMSheetname As String) Dim StartDate As String Dim STime As String Dim StartTime As Date Dim Seconds As Long Dim FirstDataRow As Long Dim LastDataRow As Long Dim secValue As Long Dim ii As Long Dim TotalSeconds As Variant Dim Hours As Long Dim Minutes As Long Dim TempTime As Variant Application.ScreenUpdating = False Sheets(QCMSheetname).Activate Columns("A:A").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Range("A10").Select ActiveCell.FormulaR1C1 = "Start Time" Columns("A:A").ColumnWidth = 19.86 StartDate = Format(Cells(2, 3).Value, "dd/mm/yyyy") STime = Format(Cells(3, 3).Value, "hh:mm:ss") Hours = Hour(STime) Minutes = Minute(STime) Seconds = Second(STime) FirstDataRow = 11 LastDataRow = Cells(1000000, 2).End(xlUp).row For ii = FirstDataRow To LastDataRow If (Not (Cells(ii, 2).Value = "")) Then secValue = Cells(ii, 2).Value TotalSeconds = secValue - Seconds TempTime = TimeSerial(Hours, Minutes, TotalSeconds) StartTime = StartDate & " " & TempTime Cells(ii, 1) = StartTime 'Cells(ii, 1) = Format(StartTime, "dd/mm/yyyy hh:mm:ss") 'TempTime = TimeSerial(Hours, Minutes, TotalSeconds) If (Format(TempTime, "hh:mm:ss") = "23:59:59") Then StartDate = DateAdd("d", 1, StartDate) Hours = 0 Minutes = 0 Seconds = secValue + 1 End If End If Next ii Application.ScreenUpdating = True End Sub
Can someone help me to resolve this issue.
at
Code:
TempTime = TimeSerial(Hours, Minutes, TotalSeconds)
Thanks
Prashant
Comment