Mounths Filtering

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,220
Office Version
  1. 2013
Platform
  1. Windows
Code:
Private Sub UserForm_Initialize()
 
Dim y As Long
  With Me
     For y = -365 To 365
     .ComboBox4.AddItem Format(Date + y, "dd-mmm-yy")
        
     Next y
    
     If Hour(Time) < 6 Then
     .ComboBox4.Text = Format(Date - 1, "dd-mmm-yy")
       
     End If
     If Hour(Time) > 6 Then
      .ComboBox4.Text = Format(Date, "dd-mmm-yy")
      
     End If
  End With
  
 
End Sub

Good Day!
How can i change this code if im going to populate only the mnths in combo box. and with the code given below filtering the dates so how can i change this code for to filter mnths.
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("a:a"), myDate) = 0 Then
          MsgBox "No Entry !"
          Exit Sub
     End If
     a = Range("a1", Range("a" & 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
Many Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,190,739
Messages
5,982,674
Members
439,790
Latest member
jonaust

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
Top