show date format (yyyy/mm/dd),numbers in listbox on userform

Alaa mg

Active Member
Joined
May 29, 2021
Messages
343
Office Version
  1. 2019
hi
I need show date format in first column in list box as in column A in sheet like this yyyy/mm/dd and show format number in columns 5,6,7 in listbox as in columns E,F,G like this #,##0.00
here is my codes
VBA Code:
Private Sub OptionButton3_Click()

If OptionButton3.Value = True And OptionButton4.Value = False Then
Label30.Caption = "cus"
End If
Dim a As Variant
 Dim i           As Long
    Dim sheetname   As String
 
    For i = 3 To 4
        With Me.Controls("OptionButton" & i)
            If .Value Then sheetname = .Caption: Exit For
        End With
    Next

ListBox1.ColumnWidths = "95;100;80;90;100;100;80"         'Column Widths Of Listbox
ListBox1.ColumnCount = 7 'Column Count Of Listbox
a = Sheets(sheetname).Range("A2:G" & Sheets(sheetname).Cells(Rows.Count, 1).End(xlUp).Row).Value
For i = LBound(a, 1) + 1 To UBound(a, 1)

Next i
ListBox1.List = a
End Sub




Private Sub OptionButton4_Click()

If OptionButton4.Value = True And OptionButton3.Value = False Then
Label30.Caption = "pay"
End If
Dim a As Variant
 Dim i           As Long
    Dim sheetname   As String
  
    For i = 3 To 4
        With Me.Controls("OptionButton" & i)
            If .Value Then sheetname = .Caption: Exit For
        End With
    Next i
  
  

ListBox1.ColumnWidths =  "95;100;80;90;100;100;80"         'Column Widths Of Listbox
ListBox1.ColumnCount = 7 'Column Count Of Listbox
a = Sheets(sheetname).Range("A2:G" & Sheets(sheetname).Cells(Rows.Count, 1).End(xlUp).Row).Value
For i = LBound(a, 1) + 1 To UBound(a, 1)
    
Next i
ListBox1.List = a
End Sub


Private Sub TextBox9_Change()
Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long
  Dim cad As String, bExists As Boolean
 
    Dim sheetname   As String
  
    For i = 3 To 4
        With Me.Controls("OptionButton" & i)
            If .Value Then sheetname = .Caption: Exit For
        End With
    Next i

  a = Sheets(sheetname).Range("A2:g" & Sheets(sheetname).Cells(Rows.Count, 1).End(3).Row).Value
  ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
  For i = 1 To UBound(a, 1)
    bExists = False
    For j = 1 To UBound(a, 2)
      If InStr(1, a(i, j), TextBox9.Value, vbTextCompare) > 0 Then
        bExists = True
        Exit For
      End If
    Next j
    If bExists Then
      k = k + 1
      For j = 1 To UBound(a, 2)
        b(k, j) = a(i, j)
      Next j
    End If
  Next i
  ListBox1.List = b
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I'm not lucky theses days whether this forum or others forums. this is the second thread without any responds .
ok after many tries and searching in the internet I got the jindon's idea and sort it out . I hope to anybody see my another thread despite of I suspect getting answer because it's really complicated .

ok here is the solution if anybody interest.
Rich (BB code):
For i = LBound(a, 1)  To UBound(a, 1)
a(i, 1) = Format$(a(i, 1), "yyyy/mm/dd")
     a(i, 5) = Format$(a(i, 5), "#,##0.00")
     a(i, 6) = Format$(a(i, 6), "#,##0.00")
     a(i, 7) = Format$(a(i, 7), "#,##0.00")
next i
note : should delete +1 from this line because will ignore first row in listbox
Rich (BB code):
For i = LBound(a, 1)+1 To UBound(a, 1)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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