water77
water77

Reputation: 123

How can I convert time (time zone)

I want to convert the time zone with 15 hours difference in excel. I can do in excel sheet by the following equation:

 =E1-(15/24)

E1 is time zone1 data with this format: (mm/dd/yy hh:mm). I don't know How can I write code of this formula in macro. Could you help me to write code?

Upvotes: 0

Views: 421

Answers (3)

water77
water77

Reputation: 123

I found the answer:

Sub TimeZone()
Range("M3:M11").Formula = "=E3 - (15/24)"
End Sub

Thank you for your help.

Upvotes: 0

Variatus
Variatus

Reputation: 14373

LocalTime = Range("E1") - (15/25) will work just the same but there is a condition.

E1 must hold a date/time value which is a number with decimals, like 43886.5 which would present 12 noon at today's date. If you deduct 15 hours from that you arrive at last night's 9 pm.

Upvotes: 1

urdearboy
urdearboy

Reputation: 14580

Just swap Excel references E1 for VBA references Range("E1")


Range("E1") = Range("E1") - (15/24)

Upvotes: 0

Related Questions