Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Fix Time conversion

Posted on 2012-03-09
2
Medium Priority
?
303 Views
Last Modified: 2012-03-09
I need Experts help to fix the time conversion script. The script is used to add 8 hours (+8), however the date conversion was not properly updated. e.g cell A2:A4 should updated as 10-Mar, by right should be 9-Mar. I have copied the actual time before conversion at Column F and G for Experts perusal.

Hope Experts could help me to fix this.

Sub ConvertDateandTime()
Dim cel As Range
For Each cel In Range("A2:A" & Range("A2").End(xlDown).Row)
cel.Value = cel.Value + Int(cel.Offset(0, 1) + 8 / 24)
cel.Offset(0, 1) = cel.Offset(0, 1) + 8 / 24 - Int(cel.Offset(0, 1) + 8 / 24)
Next cel
Columns("B:B").Select
Selection.NumberFormat = "hh:mm"

End Sub

Open in new window

Convert-Time.xls
0
Comment
Question by:Billa7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 37702925
Sub ConvertDateandTime()
Dim cel As Range
For Each cel In Range("A2:A" & Range("A2").End(xlDown).Row)
cel.Offset(0, 1).Value = cel.Offset(0, 1).Value - Int(cel.Offset(0, 1).Value)
cel.Value = cel.Value + Int(cel.Offset(0, 1) + 8 / 24)
cel.Offset(0, 1) = cel.Offset(0, 1) + 8 / 24 - Int(cel.Offset(0, 1) + 8 / 24)
Next cel
Columns("B:B").Select
Selection.NumberFormat = "hh:mm"
End Sub
0
 

Author Closing Comment

by:Billa7
ID: 37703072
Thanks a lot
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question