abdelfattah
New member
- Joined
- Jul 17, 2020
- Messages
- 10
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- 2010
hello
I have this code what I want show the last column in listbox contains values like this $1,345,444.00 , $1,000.00 , $100.00 I know this formula format listbox(i,5)=format(listbox(i,5),"$#,##0.00) but I no know where exactly adjusting
I hope somebody help
thanks
I have this code what I want show the last column in listbox contains values like this $1,345,444.00 , $1,000.00 , $100.00 I know this formula format listbox(i,5)=format(listbox(i,5),"$#,##0.00) but I no know where exactly adjusting
Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim i As Long, myCol As Long, temp, txt As String, x, a, msg As String
If Me.TextBox1 = "" Then Exit Sub
If Me.ComboBox1.Value = "" Then msg = "Select sheet first"
For i = 1 To 5
If Me("optionbutton" & i) Then
myCol = i + 1: Exit For
End If
Next
If myCol = 0 Then msg = msg & vbLf & "Select one of option buttons"
If Len(msg) Then MsgBox msg, vbCritical: Exit Sub
If myCol = 6 Then
myCol = 1
txt = "month(" & Chr(2) & ")"
Else
txt = Chr(2)
End If
Me.ListBox1.Clear
temp = Me.TextBox1
If Not IsNumeric(temp) Then temp = Chr(34) & temp & Chr(34)
If myCol Then
With Sheets(Me.ComboBox1.Value).Cells(1).CurrentRegion.Offset(1)
txt = Replace(txt, Chr(2), .Columns(myCol).Address)
Me.ListBox1.ColumnCount = .Columns.Count
x = Filter(.Parent.Evaluate("transpose(if(" & txt & "=" & _
temp & ",row(1:" & .Rows.Count & ")))"), False, 0)
If UBound(x) = 0 Then
Me.ListBox1.Column = Application.Index(.Value, x(0), 0)
Me.TextBox2.Value = Application.Index(.Value, x(0), 6)
ElseIf UBound(x) > 0 Then
Me.ListBox1.List = Application.Index(.Value, Application.Transpose(x), _
Evaluate("column(" & .Address & ")"))
Me.TextBox2.Value = Application.Sum(Application.Index(.Value, Application.Transpose(x), 6))
End If
End With
End If
thanks
Attachments
Last edited: