-1

firstly thank you for your help.

I've trying to display due dates on listbox in an userform. I'm planing add seperate CommanButtons for each months. When I click, let's say January, I want to see deadlines in January of this current year. I have 'Database' sheet, and several columns includes dates according to the progress. It may get it complicated, but I want is to bring up rows which have deadlines for January and display in Listbox. If I click December, it will update and show only rows for which deadline is December.

Please let me know if I am not clear.

Thank you in advance.

2 Answers2

0

I would recommend you use named ranges for this exercise. Select the column with all the due dates for January and name the range "Jan". Then you can use the following

Private Sub JanBtn_Click()
    DueDateLB.RowSource = "Database!Jan"
End Sub
Jeanno
  • 2,769
  • 4
  • 23
  • 31
0

thank you for your post.

So far I came up with this:


Private Sub cmdJan_Click()

Dim FindString As Date
Dim Rng As Range
FindString = DateSerial(2015, 1, 17)
With Sheets("Database").Range("N:N")
    Set Rng = .Find(What:=FindString, _
                    After:=.Cells(.Cells.Count), _
                    LookIn:=xlFormulas, _
                    LookAt:=xlWhole, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlNext, _
                    MatchCase:=False)
    If Not Rng Is Nothing Then
        Me.ListBox2.RowSource = Rng.EntireRow.Address
    Else
        MsgBox "Nothing found"
    End If
End With

End Sub


  1. I want to change "DateSerial(2015, 1, 17)" to something like "XXXX(current year, first month, any day).
  2. The code above works only when 'Database' sheet is active. It should work when it is inactive as well. 'Database' will be not hidden but only first sheet will be visible.

Any comments?