O
Optatus
I know why I'm getting the error, but I would like to know how to fix it.
The spreadsheet cells contain the following:
A1: StartDate
A2: 12/12/08
B1: EndDate
B2: 12/15/08
F1: StartTime (Unplanned)
F2: 12:20
G1: EndTime (Unplanned)
G2: 14:30
I1: TotalDowntime
I2: This cell is blank and where the end result of Main() will go.
________________________________
Sub Main()
Range("A1").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=x1Next, _
MatchCase:=False).Activate
ActiveCell.Offset(-1, 8).Activate
startdate = ActiveCell.Offset(0, -8).Value
enddate = ActiveCell.Offset(0, -7).Value
daysdown = DateDiff("D", startdate, enddate)
starttime = ActiveCell.Offset(0, -3).Value
endtime = ActiveCell.Offset(0, -2).Value
hourdiff = starttime - endtime
daysvshours = daysdown * 24 & ":00:00"
totalhours = daysvshours - hourdiff <-------------Gives the error "Type
Mismatch (Error 13)"
ActiveCell.Value = totalhours
End Sub
__________________
The spreadsheet cells contain the following:
A1: StartDate
A2: 12/12/08
B1: EndDate
B2: 12/15/08
F1: StartTime (Unplanned)
F2: 12:20
G1: EndTime (Unplanned)
G2: 14:30
I1: TotalDowntime
I2: This cell is blank and where the end result of Main() will go.
________________________________
Sub Main()
Range("A1").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=x1Next, _
MatchCase:=False).Activate
ActiveCell.Offset(-1, 8).Activate
startdate = ActiveCell.Offset(0, -8).Value
enddate = ActiveCell.Offset(0, -7).Value
daysdown = DateDiff("D", startdate, enddate)
starttime = ActiveCell.Offset(0, -3).Value
endtime = ActiveCell.Offset(0, -2).Value
hourdiff = starttime - endtime
daysvshours = daysdown * 24 & ":00:00"
totalhours = daysvshours - hourdiff <-------------Gives the error "Type
Mismatch (Error 13)"
ActiveCell.Value = totalhours
End Sub
__________________