LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Filter Month then name

Hi there I have this following code at the moment,

Private Sub Combobox1_Click()
Dim sh As Worksheet, rng As Range
Dim cnt As Long
If ComboBox1.ListIndex = -1 Then
MsgBox "Select a name first, then select a month"
Exit Sub
End If
Set sh = ActiveSheet
If sh.AutoFilterMode = True Then
If sh.FilterMode Then _
sh.ShowAllData
sh.AutoFilterMode = False
End If
Set rng = sh.Range(sh.Cells(1, 2), _
sh.Cells(1, 2).End(xlDown))
cnt = Evaluate("sumproduct(--(" & rng.Address & "=""" & _
ComboBox1.Value & """),--(" & rng.Offset(0, 1).Address & _
"=""" & cmbName & """))")

rng.Resize(, 3).AutoFilter Field:=1, Criteria1:=ComboBox1.Value

If cnt 0 Then
rng.Resize(, 3).AutoFilter Field:=2, Criteria1:=cmbName.Value
Else
rng.Resize(, 3).AutoFilter Field:=3, Criteria1:=cmbName.Value
End If
End Sub

It is running off a user form that lets them select their name from a
dropdown list and then the month they wish to look at. The month is situated
in Column B and the Names are situated in Columns C & D. I want it to first
filter the month and then filter the names colum C & D (as their name may
appear in both columns) and then show the results on the screen. If they
don't have any information for that month then I want a pop up to say "No
risks for this month........" and just show the risks relating to their name.

But I am having all sorts of trouble getting it to work.

Regards
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter out unique additions month to month Rookie_User Excel Discussion (Misc queries) 3 March 13th 09 02:29 PM
Filter by month, then day, not just day honyacker Excel Discussion (Misc queries) 1 March 21st 07 06:16 PM
Need to filter by month mikeybmdb Excel Discussion (Misc queries) 3 November 1st 05 01:53 PM
filter by month Duncan_J Excel Programming 2 April 1st 05 02:17 PM
Filter by month Marci Excel Discussion (Misc queries) 3 January 10th 05 05:53 AM


All times are GMT +1. The time now is 04:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"