Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
GIP GIP is offline
Junior Member
 
Posts: 3
Default Filter rows on sheet 2 when a certain option is chosen on sheet 1

I'm in excel 2003.
I have two worksheets in my excel workbook, "home" and "Data".
In the "home" sheet I have a combo box asking the user to choose one of 4 stages of operation. The combo box is related to cell A26 in the “home” sheet.

In the " Data " sheet I have data from row 7 - 120 in column F to V. Column Headers are in row 6.

Based on that choice that the user makes in the combo box in the "home" sheet, certain rows in the " Data " sheet should 'disappear from view' and the best way that I can think to do this is with Autofilter.
For example, if they choose “stage 1” in the combo box, then all rows that are (in column G) labeled as anything else other than “stage 1” will disappear.

That is the theory, but I don't seem able to actually make it happen. My code seems to work as soon as there is a change in the combo box and choose the correct cells for the autofilter, but then it doesn’t actually filter anything! Anyone able to help out by letting me know where the errors are in my code below, or providing a different code in order to accomplish my task?

Am I possibly using the wrong field number?

Code says basically:
- unprotect the worksheet,
- remove filters (in case they were already there),
- based on what the user chooses, add filters and filter the rows required in the “Data” sheet,
- select a cell in the "home" sheet

Code is as follows:


Private Sub ComboBox1_Change()

Application.ScreenUpdating = False
Worksheets("Data ").Unprotect ("password")
Sheets("Data ").AutoFilterMode = False

Dim sel1 As Variant
Set sel1 = Worksheets("home").Cells(1, 26)

Sheets("Data ").Range("F6:V6").AutoFilter Field:=2, Criteria1:=sel1
Worksheets("Data ").Protect Password:="password", DrawingObjects:=True, UserInterfaceOnly:=True, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True

Worksheets("home").Cells(24, 10).Select

End Sub
  #2   Report Post  
GIP GIP is offline
Junior Member
 
Posts: 3
Default

Quote:
Originally Posted by GIP View Post
I'm in excel 2003.
I have two worksheets in my excel workbook, "home" and "Data".
In the "home" sheet I have a combo box asking the user to choose one of 4 stages of operation. The combo box is related to cell A26 in the “home” sheet.

In the " Data " sheet I have data from row 7 - 120 in column F to V. Column Headers are in row 6.

Based on that choice that the user makes in the combo box in the "home" sheet, certain rows in the " Data " sheet should 'disappear from view' and the best way that I can think to do this is with Autofilter.
For example, if they choose “stage 1” in the combo box, then all rows that are (in column G) labeled as anything else other than “stage 1” will disappear.

That is the theory, but I don't seem able to actually make it happen. My code seems to work as soon as there is a change in the combo box and choose the correct cells for the autofilter, but then it doesn’t actually filter anything! Anyone able to help out by letting me know where the errors are in my code below, or providing a different code in order to accomplish my task?

Am I possibly using the wrong field number?

Code says basically:
- unprotect the worksheet,
- remove filters (in case they were already there),
- based on what the user chooses, add filters and filter the rows required in the “Data” sheet,
- select a cell in the "home" sheet

Code is as follows:


Private Sub ComboBox1_Change()

Application.ScreenUpdating = False
Worksheets("Data ").Unprotect ("password")
Sheets("Data ").AutoFilterMode = False

Dim sel1 As Variant
Set sel1 = Worksheets("home").Cells(1, 26)

Sheets("Data ").Range("F6:V6").AutoFilter Field:=2, Criteria1:=sel1
Worksheets("Data ").Protect Password:="password", DrawingObjects:=True, UserInterfaceOnly:=True, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True

Worksheets("home").Cells(24, 10).Select

End Sub

I have attached the worksheet so anyone can try play with the code for real.
Thanks.
Attached Files
File Type: zip 20100819 Autofilter Code.zip (9.8 KB, 41 views)
Reply
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
Excel 2007 can not filter / sort in sheet with 657,000 rows Charlie Ruddy Excel Discussion (Misc queries) 1 December 30th 07 01:17 AM
Filter Range on Sheet B Based on List on Sheet A Brent E Excel Discussion (Misc queries) 4 April 23rd 07 04:10 PM
How to paste data over the hidden rows in a sheet with a filter hezemeftez Excel Discussion (Misc queries) 2 August 2nd 06 03:29 PM
'Copy to' Advance Filter depend only on sheet ID not start sheet Sandy Yates Excel Worksheet Functions 0 April 4th 06 03:48 AM
Opening a workbook to a chosen sheet? renderingsanity Excel Discussion (Misc queries) 1 March 29th 06 02:17 PM


All times are GMT +1. The time now is 07:51 AM.

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

About Us

"It's about Microsoft Excel"