number format in three columns into listbox on useform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,494
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hello
I want showing number formatting like this #,##0.00 in columns 8,9,10 in list box . I try to add some lines as bold lines, but I failed.
Rich (BB code):
Private Sub LBoxPop()
    Dim I, myFormat(1) As String
   Dim lindex&
  Data = ws.Cells(1).CurrentRegion.Value: x = 0
  myFormat(0) = ws.Cells(2, 8).NumberFormatLocal
  myFormat(1) = ws.Cells(2, 9).NumberFormatLocal
  ReDim Temp(1 To UBound(Data, 1), 1 To 10)
  For I = 1 To UBound(Data)
    If Data(I, 4) Like Crit & "*" Or Data(I, 4) = "C??  C?????" Then
      x = x + 1
      Temp(x, 2) = Format(Data(x, 2), "DD/MM/YYYY")
      For ii = 1 To 10
        Temp(x, ii) = Data(I, ii)
      Next ii
    End If
  Next I
 
  With UserForm1.ListBox1
            .List(lindex, 7) = Format$(.List(lindex, 7), myFormat(0))
            .List(lindex, 8) = Format$(.List(lindex, 8), myFormat(1))
            .List(lindex, 9) = Format$(.List(lindex, 9), myFormat(1))
    .ColumnCount = 10
    .ColumnWidths = "80;80;120;80;60;60;60;60;60;60"
    .List = Temp
  End With
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I want showing number formatting like this #,##0.00 in columns 8,9,10 in list box .

You must do it value by value and for each row.

Try the following;
VBA Code:
Private Sub LBoxPop()
  Dim i&, ii&
  Dim myFormat(1) As String
  
  Data = ws.Cells(1).CurrentRegion.Value
  x = 0
  myFormat(0) = ws.Cells(2, 8).NumberFormatLocal
  myFormat(1) = ws.Cells(2, 9).NumberFormatLocal
  
  ReDim Temp(1 To UBound(Data, 1), 1 To 10)
  
  For i = 1 To UBound(Data)
    If Data(i, 4) Like crit & "*" Or Data(i, 4) = "C??  C?????" Then
      x = x + 1
      Temp(x, 2) = Format(Data(x, 2), "DD/MM/YYYY")
      For ii = 1 To 10
        Temp(x, ii) = Data(i, ii)
        If ii >= 8 Then
          Temp(x, ii) = Format$(Data(i, ii), myFormat(1))
        End If
      Next ii
    End If
  Next i
 
  With UserForm1.ListBox1
    .ColumnCount = 10
    .ColumnWidths = "80;80;120;80;60;60;60;60;60;60"
    .List = Temp
  End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,868
Messages
6,175,082
Members
452,611
Latest member
bls2024

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