attach is my code (I copy from one of the online project and suiting to my need, so u can see a lot of comment because im doing editing through trial and error)
The proper date "if" im not using it but I am afraid i might leak out some clue if i deleted it.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdFilter_Click()
- Dim ws As Worksheet
- 'set worksheet variable
- Set ws = Sheet1
- 'Make sure it is a proper date
- 'If Not IsDate(Me.txtDateStart) And Me.txtDateStart <> "" Then
- 'MsgBox "This is not a proper date"
- 'Me.txtDateStart = ""
- 'Exit Sub
- 'End If
- 'Make sure it is a proper date
- 'If Not IsDate(Me.txtDateFinish) And Me.txtDateFinish <> "" Then
- 'MsgBox "This is not a proper date"
- 'Me.txtDateFinish = ""
- 'Exit Sub
- 'End If
- 'send the values to the worksheet
- With ws
- '.Range("C6").Value = Format(Me.txtDateStart.Value, "dd/mm/yyyy")
- '.Range("D6").Value = Format(Me.txtDateFinish.Value, "dd/mm/yyyy")
- .Range("AO2").Value = Me.Sc1.Value
- .Range("AP2").Value = Me.Sc2.Value
- .Range("AQ2").Value = Me.Sc3.Value
- .Range("AR2").Value = Me.Sc4.Value
- .Range("AS2").Value = Me.Sc5.Value
- .Range("AT2").Value = Me.Sc6.Value
- .Range("AU2").Value = Me.Sc7.Value
- .Range("AV2").Value = Me.Sc8.Value
- .Range("AW2").Value = Me.Sc9.Value
- .Range("AX2").Value = Me.Sc10.Value
- .Range("AY2").Value = Me.Sc11.Value
- End With
- 'run the advanced filter
- 'If ws.Range("N9").Value <> "" Then
- 'Me.lstTool.RowSource = ""
- Filterme
- 'Clearme
- 'End If
- 'add the named range to the rowsource
- 'If ws.Range("AC9").Value = "" Then
- 'Me.lstTool.RowSource = "outdata"
- 'MsgBox "No matching data"
- 'Else
- Me.lstTool.RowSource = "FilterData"
- 'End If
- End Sub