Solved

Fix Time conversion

Posted on 2012-03-09
2
293 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

749 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