Consulting

Results 1 to 5 of 5

Thread: Listview and hh:mm format

  1. #1

    Listview and hh:mm format

    Hello


    Why in a listview showing a cell (with hh:mm format) I have 0,85752?

    I don't understand why and how to have hh:mm format in a listwiew on a userform?


    Thanks for your help.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by oleneazer
    Hello


    Why in a listview showing a cell (with hh:mm format) I have 0,85752?

    I don't understand why and how to have hh:mm format in a listwiew on a userform?


    Thanks for your help.
    You need to format it when you laod the ListView

    e.g. Format(Range("A1"),"hh:mm")

  3. #3
    Tahnk's for your answer
    , but the problem is still there.


    Here's the code
    and I've still 0,xxxx in the listview

    So i do this
    the value o f the cell
    = "'" & FormaDateTime(Time,4) but i wan't to know how to format the listview properly.

    [vba]With ListView1
    With .ColumnHeaders
    .Clear
    .Add , , "AAA", 60
    .Add , , "BBB", 60
    .Add , , "HEURE", 60
    .Add , , "DDD", 80
    End With

    For Each Cell In Sheets(1).Range("A2:A11")
    X = X + 1
    .ListItems.Add , , Cell
    .ListItems(X).ListSubItems.Add , , Cell.Offset(0, 1)
    .ListItems(X).ListSubItems.Add , , Cell.Offset(0, 2)
    .ListItems(X).ListSubItems.Add , , Format(Cell.Offset(0, 3), "hh:mm")
    .ListItems(X).ListSubItems.Add , , Cell.Offset(0, 4)
    Next

    End With[/vba]

  4. #4
    You can see in the attachment

    that it doesn' work

  5. #5
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    I think you've just confused which column to format.
    According to your example, the time column is col 3. This will be the reference cell (column 1) offset by 2 columns[VBA].ListItems.Add , , Cell
    .ListItems(X).ListSubItems.Add , , Cell.Offset(0, 1)
    .ListItems(X).ListSubItems.Add , , Format(Cell.Offset(0, 2), "hh:mm")
    .ListItems(X).ListSubItems.Add , , Cell.Offset(0, 3)[/VBA]
    K :-)

Posting Permissions

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