Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2017, 03:20 AM
sprit36 sprit36 is offline Advance one hour Windows 10 Advance one hour Office 2010 64bit
Novice
Advance one hour
 
Join Date: Jul 2017
Posts: 9
sprit36 is on a distinguished road
Default Advance one hour


Good morning, I have some time slots, and I need to advance one hour to the whole time slot, I have tried several things without success. There is some way forward for an hour at all times as they are different. I attach an example. Attached example marked in green is the expected result. Thank you.
Attached Files
File Type: xls Hour2.xls (36.5 KB, 11 views)
Reply With Quote
  #2  
Old 07-19-2017, 09:13 AM
NoSparks NoSparks is offline Advance one hour Windows 7 64bit Advance one hour 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

Give this a shot...
Code:
Sub AdvanceTimes()

    Dim tmp, cel As Range
    Dim firstTime As String
    Dim secondTime As String
    
With Sheets("Sheet1")
    For Each cel In .Range("B3:C25")
        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
    Next cel
End With
End Sub
Reply With Quote
  #3  
Old 07-19-2017, 11:35 PM
sprit36 sprit36 is offline Advance one hour Windows 10 Advance one hour Office 2010 64bit
Novice
Advance one hour
 
Join Date: Jul 2017
Posts: 9
sprit36 is on a distinguished road
Default

Thank you very much, it works perfectly. A doubt only, if there is some text in the schedule like for example vacations, appears error 13. Is there any way to solve it? Thank you very much for your help.
Reply With Quote
  #4  
Old 07-20-2017, 07:43 AM
NoSparks NoSparks is offline Advance one hour Windows 7 64bit Advance one hour 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
  #5  
Old 07-20-2017, 11:56 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Advance one hour Windows 7 64bit Advance one hour Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

We are here to help so help us to help you!

Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #6  
Old 07-21-2017, 12:14 AM
sprit36 sprit36 is offline Advance one hour Windows 10 Advance one hour Office 2010 64bit
Novice
Advance one hour
 
Join Date: Jul 2017
Posts: 9
sprit36 is on a distinguished road
Default

NoSparks thank you very much for your help, it works very well. It's fixed. Pecoflyer I apologize for cross-posts, in the other forum I had not received an answer, that's the reason I opened it in this forum. He does not know the rules. I already know them and will not happen again.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting difference in time as a decimal and percentage of an hour shabbaranks Excel 2 05-23-2017 07:22 AM
Advance one hour 24 hour task calendar doesn't show a day?? benl Project 3 12-31-2015 02:55 PM
12 hour work days (shifts) John Franklin Project 22 11-12-2013 03:19 PM
Can Excel Deduct 30 Minutes from an 8 1/2 Hour Cell? tatihulot Excel 4 05-16-2013 04:30 PM
Advance one hour Half hour added between tasks maruchi Project 1 06-17-2010 08:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft