Results 1 to 15 of 15

Thread: [Resolved]Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Resolved [Resolved]Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    Hi,

    I am extracting values in the format of hh:mm:ss from one spreadsheet and storing it into a string
    i then add the value stored in that string to another value stored in another string(hh:mm:ss)

    when i then paste the new value into another workbook, the format becomes
    dd/mm/yy hh:mm:ss
    and in the example below the format of the destination cell becomes "scientific", although i had already set the format to hh:mm:ss

    do you know how i can sort this, is it because i am adding variables using cells?

    here is an example of part of the code, as this is kinda hard to explain
    the variables that end in "t" are my temp variables


    VB Code:
    1. 'location of unavailable
    2.     ranPers.Cells(201).Select
    3.     strUnavailt = ActiveCell.Value
    4.     Range("K1").Value = strUnavailt
    5.     Range("K2").Value = strUnavail
    6.     Range("K3").Formula = "=sum(K1:K2)"
    7.     strUnavail = Range("K3").Value
    8.     Range("K1:K3").Clear
    Last edited by Mitch_s_s; Feb 9th, 2007 at 09:50 AM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    does this help?

    VB Code:
    1. Private Sub CommandButton1_Click()
    2.  
    3. 'Extracting value from a cell
    4. str1 = Sheets("Sheet1").Range("A1").Value
    5.  
    6. 'Say a string which has a value in "hh:mm:ss" format
    7. str2 = "08:00:00"
    8.  
    9. 'Adding them
    10. Sum = Val(Format(str1, "0.00")) + Val(Format(str2, "0.00"))
    11.  
    12. 'storing the sum in another cell in another sheet
    13. Sheets("Sheet2").Range("A10").Value = Sum
    14. 'changing the format of this cell to "hh:mm:ss" format
    15. Sheets("Sheet2").Range("A10").NumberFormat = "hh:mm:ss"
    16.  
    17.  
    18. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    cheers mate

    when i change the format to hh:mm:ss it remains the other way

    i right click and edit the cells properties

    what my sub does is go through the worksheet and adds up certain cells depending on whether the title of the range meets the criteria
    as its loopin its doin the above code

    is it the way vba is storin the code?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    when the macro has run

    if i format the cell to be hh:mm:ss
    it remains in the format of dd/mm/yy hh:mm:ss

    is this because it may have exceded 24 hours?
    which it more than likely has....

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    it's in work, i will go in tomorrow and email it to myself
    then i will up it

    but it basically loops and counts up all the unavailable time for each individual on each time
    ie team 1
    it will sum all the unavailable time for team one, and will store it in strUnavail

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    Oh... Ok

    try this
    VB Code:
    1. Private Sub CommandButton1_Click()
    2.  
    3. 'Extracting value from a cell
    4. str1 = Sheets("Sheet1").Range("A1").Value
    5.  
    6. 'Say a string which has a value in "hh:mm:ss" format
    7. str2 = "08:00:00"
    8.  
    9. 'Adding them
    10. Sum = Val(Format(str1, "0.00")) + Val(Format(str2, "0.00"))
    11.  
    12. 'storing the sum in another cell in another sheet
    13. Sheets("Sheet2").Range("A10").Value = Sum
    14. 'changing the format of this cell to "[h]:mm:ss" format
    15. 'so it shows the sum....
    16. Sheets("Sheet2").Range("A10").NumberFormat = "[h]:mm:ss"
    17.  
    18. End Sub

    Does this help?

    ps: Are you working in a contact centre?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    yeah
    we use seagate enterprise reports
    but they wont change them as we are getting rid of rockwell at the end of the year

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    yeah
    we use seagate enterprise reports
    but they wont change them as we are getting rid of rockwell at the end of the year
    Me too
    rockwell Issss... pathetic...
    I think now your problem will be solved... check it out...
    Have changed the format to "[h]:mm:ss"
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    what do the [ ] 's do to the formatting?

    we're going to cisco(sP) the back end of 2007
    so no development will be happenin with any rockwell reports

    its better in the long run as we will be getting business objects, i will test this out when i'm next in work
    not gonna go in tomorrow, cant be bothered lol

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    If you are working with times and you want Excel to display hours greater than 24, use the custom format [h]:mm:ss
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    sound

    that will do me, tar for that mate
    do i just rate one post or all?

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    i'll check in work, when i'm next in then i will update

    cheers

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    heres attached my files

    cant suss it out

    doesnt appear to be calculating AHT and total handled time correctly...
    Attached Files Attached Files

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    oops!
    RTM

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Cell Formats - hh:mm:ss converts to dd/mm/yy hh:mm:ss

    ^pass

Posting Permissions

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



Click Here to Expand Forum to Full Width