number formatt"#,##0.00" doesn't work in two columns in listbox on form

Mussala

Board Regular
Joined
Sep 28, 2022
Messages
87
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I try to show amounts in column 4,5 in list box on form like this ("#,##0.00) but doesn't work as in bold lines!!:rolleyes:
Rich (BB code):
Sub LoadData()

    Dim s$(1), x, e
    For Each e In Array("Mussala", "mssau", "mjhgsg")
        s(0) = s(0) & IIf(s(0) = "", "", "Union All (") & "Select " & _
        "Format(`DATE`,'dd/mm/yyyy'), `INVOICE NO`, `TYPE`, `DEBIT`, `CREDIT`, " & _
        "`BALANCE` From `" & e & "$` Where `TYPE` <> 'OPENING' And `TYPE` Is Not Null " & IIf(s(0) = "", "", ") ")
    Next
    s(1) = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" & ThisWorkbook.FullName & _
         ";Extended Properties='Excel 12.0;HDR=Yes';"
    With CreateObject("ADODB.Recordset")
        .Open s(0), s(1), 3, 3, 1
        x = .GetRows
    End With
    With Me.ListBox1
        .ColumnCount = UBound(x, 1) + 1
        .Column = x
        For i = 0 To ListCount - 1
    .List(i, 3) = Format(.List(i, 3), "#,##0.00")
     .List(i, 4) = Format(.List(i, 4), "#,##0.00")
     Next i
    End With
   
End Sub
what's the problem guys?!:confused:
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello,
I try to show amounts in column 4,5 in list box on form like this ("#,##0.00) but doesn't work as in bold lines!!:rolleyes:
what's the problem guys?!:confused:

Try including the period (full stop) in front of ListCount

Rich (BB code):
       For i = 0 To .ListCount - 1
            .List(i, 3) = Format(.List(i, 3), "#,##0.00")
            .List(i, 4) = Format(.List(i, 4), "#,##0.00")
        Next i

Dave
 
Upvote 0
Solution
Oops!:oops:
good catching .
but strangely doesn't show me error like syntax and still doesn't work after add period !
 
Upvote 0
Try this additional change:
Rich (BB code):
       For i = 0 To .ListCount - 1
            .List(i, 3) = Format(CCur(.List(i, 3)), "#,##0.00")
            .List(i, 4) = Format(CCur(.List(i, 4)), "#,##0.00")
        Next i
 
Upvote 0
thanks Alex
your way shows me error invalid used o null in this line
VBA Code:
.List(i, 3) = Format(CCur(.List(i, 3)), "#,##0.00")
any way my problem is fixed.;)
 
Upvote 0

Forum statistics

Threads
1,225,609
Messages
6,185,985
Members
453,333
Latest member
BioCoder84

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