Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Morning all.
A while back Don Guillett provided me with a filter routine that has been working really well-- with a single exception. My sheet names that I'm calling to don't always remain constant. I.e., sometimes it'll be Sum, with others it'll be Summary, SUMMARY, etc..... I'd like to get the routine to accept all variations of Sum, without me having to rewrite the elements to take into account the different name each time I run the routine in a new workbook. Here's the code. ------------------------------------------------------------------------ Sub FilterA() Dim wks As Worksheet 'I added this because I wanted to get a name variable 'for a worksheet mv = Range("f3").End(xlDown).value ' this sets the criteria. Select Case wks.Name 'I looked at another macro that I have and see that it used Select to account for 'all name variables. Case "Sum", "Summary", "SUM", "summary", "SUM ", "Sum ", "Summary ", "SUMMARY", "SUMMARY " 'this is the code that I pulled from the other macro accounting for the name 'variables. With wks Sheets(wks.Name).Range("A8:F8").AutoFilter field:=1, Criteria1:=mv 'the original version that Don G. provided gave 'Sheets("Sum")....... It's here that I need to do the variable name. mv1 = Range("a3").End(xlDown).value 'this is my add-on to set a second criteria filter- Name of owner. 'And here too to account for variable sheet name. Sheets(wks.Name).Range("A8:F8").AutoFilter field:=3, Criteria1:=mv1 'this takes in to account the owner name for a filter. End With End Select End Sub ------------------------------------------------------------ I had thought this would work, but it throws a 91 error-- object variable or with block not set. What do I need to do to set the object variable? I'm assuming that is my issue. Thank you. Best, SteveB. I'm running Excel 2007. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Particulars data Filter from sheet 1 to sheet 2 automatically | Excel Worksheet Functions | |||
Filter Range on Sheet B Based on List on Sheet A | Excel Discussion (Misc queries) | |||
'Copy to' Advance Filter depend only on sheet ID not start sheet | Excel Worksheet Functions | |||
Can you filter sheet of data & on another sheet make four groups under each other? | Excel Programming | |||
Need help with writing variant back to sheet | Excel Programming |