Solved

Fix Time conversion

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now