+ Reply to Thread
Results 1 to 17 of 17

Macro for converting Time Zone

  1. #1
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Macro for converting Time Zone

    Hi,

    I am looking for a macro to convert time from IST to CST. I have attached the spread sheet, in which sheet2 is having IST & Sheet1 is having CST.

    I need a Macro to look at ColumnC, ColumnD & ColumnE of Sheet2 and paste the converted result in sheet1 as shown in the attached sheet. It need to look till the last cell of ColumnA every time I run this, as the data is not constant. If any of the cell in empty then it need to copy empty cell instead of negative values.

    I have used the following formula for converting the time

    Please Login or Register  to view this content.
    Thanks in advance for all your help!!

    Regards,
    Humac
    Attached Files Attached Files
    Last edited by humacdeep; 09-21-2011 at 06:04 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    The macro below has been added to a button on Sheet1. This will fill the table with the formulae to display the times.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Hi Leith,

    The code is not working as desired. Sorry if my earlier request is not clear.

    I have attahed the modified sheet, in sheet1 the result is from Macro, Sheet2 has orginal data, Sheet3 is having the desired result.

    Regards,
    Humac
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Macro for converting Time Zone

    What are IST and CST ?

  5. #5
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Hi Arthur,

    IST is Indian Standard Time & CST is Central Standard Time.

    Regards,
    Humac

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Macro for converting Time Zone

    Thx,
    this will help the members unaware of that information.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    I revised the macro and added it to the workbook below. Here is the revised code.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Thanks for the code Leith!!

    It is working fine if I copy the data in Sheet1 from Sheet2. I tried deleting data in sheet1 and run the Macro then I am getting error 400.

    Does this code copy the data in sheet1 from sheet2 or Do I need to manually paste it in sheet1 and run the Macro?

    Regards,
    Humac

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    I assumed the table already existed on Sheet1 and the macro expects the same. It simply adds the needed formulas.

  10. #10
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Thanks for the reply!!

    Is it possible to get the result directly in Sheet1 from Sheet2?

    Regards,
    Humac

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    If you mean can the macro copy the table from Sheet2 to Sheet1 and then add the formulas to the table on Sheet1 then the answer is yes. If that is not what you want then I need more details.

  12. #12
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Yes Leith, I want macro to copy the table from Sheet2 to Sheet1 and then add the formulas to the table on Sheet1.

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro for converting Time Zone

    alternative:

    Please Login or Register  to view this content.



  14. #14
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Thanks SNB, it works but it is only coping the columns from C:E, I need entire data to be copied from sheet2 to sheet1. Also if possible it should clear the existing data from sheet1 before pasting the result.

    There was a typo in the above code, it should be Time(10,30,0).

    Regards,
    Humac

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    This version of the macro copies the table from "Sheet2" to "Sheet1" then adds the formulas. It has been added to the attached workbook.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    09-10-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    176

    Re: Macro for converting Time Zone

    Thanks Leith for your time & patience!!

    Its really working like a charm

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro for converting Time Zone

    Hello humacdeep,

    You're welcome. Glad we got it straightened out and working right.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1