N
Nigel Brown
I am struggling to find a method to display dates correctly in a
listbox. I populate the listbox with the following code.
Private Sub testlist()
Dim rng As Range
Dim cw
Dim colcnt As Integer
Dim rowcnt As Integer
colcnt = ActiveSheet.UsedRange.Columns.Count
rowcnt = ActiveSheet.UsedRange.Rows.Count
str = "a2:g" & rowcnt
Set rng = Range(str)
With ListBox1
.ColumnCount = colcnt
.ColumnHeads = True
.RowSource = rng.Address
cw = ""
For i = 1 To .ColumnCount
cw = cw & rng.Columns(i).Width & ";"
Next
.ColumnWidths = cw
.ListIndex = 0
End With
End Sub
The problem is that column g on the worksheet contains dates and these
are being displayed as values in the listbox. The format I want to
used is "DD/MM/YYYY". Any help will be greatly appriciated.
Nigel Brown
Theisen Securities.
listbox. I populate the listbox with the following code.
Private Sub testlist()
Dim rng As Range
Dim cw
Dim colcnt As Integer
Dim rowcnt As Integer
colcnt = ActiveSheet.UsedRange.Columns.Count
rowcnt = ActiveSheet.UsedRange.Rows.Count
str = "a2:g" & rowcnt
Set rng = Range(str)
With ListBox1
.ColumnCount = colcnt
.ColumnHeads = True
.RowSource = rng.Address
cw = ""
For i = 1 To .ColumnCount
cw = cw & rng.Columns(i).Width & ";"
Next
.ColumnWidths = cw
.ListIndex = 0
End With
End Sub
The problem is that column g on the worksheet contains dates and these
are being displayed as values in the listbox. The format I want to
used is "DD/MM/YYYY". Any help will be greatly appriciated.
Nigel Brown
Theisen Securities.