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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

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