Format columns in a listbox as Currency

Lars1

Board Regular
Joined
Feb 3, 2021
Messages
154
Office Version
  1. 365
Platform
  1. Windows
Hi
I am quite new to VBA, and i have a problem with som formats in a listbox.
I would like column 8 and column 10 formatted as currency #.###,## kr the Danish format.

As it is now it comes out with plain numbers like 1000 and the result i am looking for is 1.000,00 kr

There are also two columns formatted as "Short Time", but this is maybe not the best way to format these two columns :)



Private Sub FillContacts(Optional sFilter As String = "*")
Dim i As Long, j As Long

'Clear any existing entries in the ListBox
Me.ListBox1.Clear

'Loop through all the rows and columns of the contact list
For i = LBound(maContacts, 1) To UBound(maContacts, 1)
For j = 1 To 10
'Compare the contact to the filter
If UCase(maContacts(i, j)) Like UCase("*" & sFilter & "*") Then
'Add it to the ListBox
With Me.ListBox1
.AddItem maContacts(i, 1)
.List(.ListCount - 1, 1) = maContacts(i, 2)
.List(.ListCount - 1, 2) = maContacts(i, 3)
.List(.ListCount - 1, 3) = maContacts(i, 4)
.List(.ListCount - 1, 4) = maContacts(i, 5)
.List(.ListCount - 1, 4) = Format(Time, "Short Time")
.List(.ListCount - 1, 5) = maContacts(i, 6)
.List(.ListCount - 1, 5) = Format(Time, "Short Time")
.List(.ListCount - 1, 6) = maContacts(i, 7)
.List(.ListCount - 1, 7) = maContacts(i, 8)
.List(.ListCount - 1, 8) = maContacts(i, 9)
.List(.ListCount - 1, 9) = maContacts(i, 10)
End With
'If any column matched, skip the rest of the columns
'and move to the next contact
Exit For
End If
Next j
Next i
'Select the first contact
If Me.ListBox1.ListCount > 0 Then Me.ListBox1.ListIndex = 0
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Perfect... Everything is in there :)
just a small correction / question...
How to change format to 09 : 05
1613722043332.png



AND...
When i click on "Save new record" the listbox shows all records
When i click on "Finalise record" the listbox shows all records.
How to only show records for the relevant employee ?
 
Upvote 0
have to look at the record filter still. i can fix the show all records after click easily

formatting change
VBA Code:
    With ws
        .Cells(lRow, 1).Value = cboID.Value
        .Cells(lRow, 2).Value = cboID.List(lPart, 1)
        .Cells(lRow, 4).Value = Format(txtDate.Value, "dd-mmm-yyyy")
        tempStart = Format(txtStart.Text, "00") & ":" & Format(txtStart2.Text, "00")
        .Cells(lRow, 5).Value = tempStart
 
Upvote 0
VBA Code:
Private Sub cboID_Change()
    If cboID.ListIndex = -1 Then
        Frame1.Visible = False
    Else
        Frame1.Visible = True
        FillContacts cboID.Text
    End If
    Frame2.Visible = False
End Sub
 
Upvote 0
VBA Code:
Private Sub cboID_Change()
    If cboID.ListIndex = -1 Then
        Frame1.Visible = False
    Else
        Frame1.Visible = True
        FillContacts cboID.Text
    End If
    Frame2.Visible = False
End Sub
Then the ListBox is not updated unless i change to a new user and then go back
 
Upvote 0
Nice solution (y)
But it looks like the ListBox is not showing records before i change to another user and go back again...

I have changed the default OptionButton to 2.
OptionButton2.Value = True
 
Upvote 0
what is the sequence of actions you are doing to make the problem
 
Upvote 0

Forum statistics

Threads
1,215,777
Messages
6,126,838
Members
449,343
Latest member
DEWS2031

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