asyamonique
Well-known Member
- Joined
- Jan 29, 2008
- Messages
- 1,220
- Office Version
-
- 2013
- Platform
-
- Windows
Could anybody pls. help me in regards given code below??
I need to change this code for filtering the months instead of dates.Located data on the column B with text value of 12 months 'jan to dec.'
My Best Regards
I need to change this code for filtering the months instead of dates.Located data on the column B with text value of 12 months 'jan to dec.'
Code:
Private Sub CommandButton1_Click()
Sheet2.Select
Dim a, i As Long, ii As Long, b(), n As Long, myDate As Date
ListBox2.Clear
With ComboBox4
If .Value = "" Then Exit Sub
myDate = DateValue(.Value)
If WorksheetFunction.CountIf(Range("b:b"), myDate) = 0 Then
MsgBox "No Entry !"
Exit Sub
End If
a = Range("b1", Range("b" & Rows.Count).End(xlUp)).Resize(, 3).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = myDate Then
n = n + 1: ReDim Preserve b(1 To 3, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
b(1, n) = Format$(a(i, 1), "dd-mmm-yy")
End If
Next
End With
With ListBox2
.ColumnCount = 3
.ColumnWidths = "60;420;30"
.Column = b
End With
With Application
Me.TextBox2.Value = .Sum(.Index(b, 3, 0))
End With
End Sub
Last edited: