Format Multiple Listbox Columns

  • I am trying to adapt a search/edit/delete userform I found on this site. Unfortunatly I can't find it again.


    I have 10 columns in a listbox that is populated from a search. This all works well.
    What I want to do is format columns 5, 6, 7, & 9 to date format (dd/mmm/yyyy)


    I have managed to get it to do a single column (5) but have been unable to change the others.


    The code I am using is:


    Can any one point me in the right direction?
    Many thanks


    Windy

  • Re: Format Multiple Listbox Columns


    Here is an example of adding dates from a 2 column Named Range into a 2 Column ListBox;

  • Re: Format Multiple Listbox Columns


    p45cal



    Quote from p45cal

    Take a look at here.
    p45cal


    I have looked at that but not sure where to place it in relation to my original code.
    Could you point me in the right direction?


    Windy :yourock:

  • Re: Format Multiple Listbox Columns


    Untested:Try replacing your blocks of code beginning:

    Code
    For ii = 1 To 10


    with either:

    Code
    If ii = 5 Or ii = 6 Or ii = 7 Or ii = 9 Then
      a(ii, i) = Format(.Cells(r.Row, ii), "dd/mmm/yyyy")
    Else
      a(ii, i) = .Cells(r.Row, ii).Value
    End If


    or:

    Code
    Select Case ii
      Case 5, 6, 7, 9
        a(ii, i) = Format(.Cells(r.Row, ii), "dd/mmm/yyyy")
      Case Else
        a(ii, i) = .Cells(r.Row, ii).Value
    End Select


    p45cal

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!