View Single Post
 
Old 07-20-2017, 07:43 AM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Quote:
A doubt only, if there is some text in the schedule like for example vacations, appears error 13.
Every cell in your schedule is text, even the times are text not real times.

Provided none of your 'for example vacations' have a colon at the third character position this should do it.
Code:
Sub AdvanceTimes_v2()

    Dim tmp, cel As Range
    Dim firstTime As String
    Dim secondTime As String
    
With Sheets("Sheet1")
    For Each cel In .Range("B3:C25")
        If InStr(Trim(cel.Value), ":") = 3 Then
            tmp = Split(cel.Value, "-")
            firstTime = CStr(Format(DateAdd("h", 1, CDate(tmp(0))), "hh:mm"))
            secondTime = CStr(Format(DateAdd("h", 1, CDate(tmp(1))), "hh:mm"))
            cel.Value = firstTime & "-" & secondTime
        End If
    Next cel
End With
End Sub
Question... why are you using xls file when your profile indicates Office 2010 64bit ?
Reply With Quote