Userform Listbox column date format

vhdhfox

New Member
Joined
Aug 6, 2020
Messages
36
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have a listbox with 14 columns and in column 1(0) I have a date which I have code that does work but only for the first row as shown below

1599025382160.png


and the code im using


VBA Code:
Sub UserForm_Initialize()
    Dim lindex&
    Dim rngMultiColumn As Range
    Set rngMultiColumn = ThisWorkbook.Worksheets("Sheet1").Range("A4:N100")
        With Me.AllocateBox1
        .ColumnCount = 14
        .ColumnWidths = "40;50;50;80;35;30;30;90;60;70;75;85;30"
        .List = rngMultiColumn.Cells.Value
        .List(lindex, 0) = (Format((.List(lindex, 0)), "dd-mmm"))
        End With
    
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
VBA Code:
Sub UserForm_Initialize()
   Dim lIndex As Long
   Dim rngMultiColumn As Range
   Set rngMultiColumn = ThisWorkbook.Worksheets("Sheet1").Range("A4:N100")
   With Me.AllocateBox1
      .ColumnCount = 14
      .ColumnWidths = "40;50;50;80;35;30;30;90;60;70;75;85;30"
      .List = rngMultiColumn.Cells.Value
       For lIndex = 0 To .ListCount - 1
          .List(lIndex, 0) = Format(.List(lIndex, 0), "dd-mmm")
       Next lIndex
   End With
    
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top