Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel filter does not working anymore

Can anyone help me with this problem:

I use a code in my excel sheet to hide rows when there is a "0" (zero)
or a "C" is in a cell in the colomn. Now when I use my auto filter,
it's not filtering anything!

This is how my sheet lookslike:

1 C
1 H
2 M
2 T
3 K
3 H
4 0

This is how the code lookslike:

Dim X As Boolean

Private Sub Worksheet_Calculate()
Dim R As Long
If X = True Then Exit Sub
X = True
For R = 1 To Cells(65535, 3).End(xlUp).Row
Select Case Cells(R, 3).Value
Case "", 0, "C"
Me.Rows(R).Hidden = True
Case Else
Me.Rows(R).Hidden = False
End Select
Next
X = False
End Sub

What I want is to use the auto filter on the rows, but if I do this
now, the filter does not filter anything!

Who can help with this problem?

Greets, Berry

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel filter does not working anymore

When you posted this before, you were asked what X equals.

I don't recall seeing your response.

But if X is set to True, then your code simply exits the routine.

And is there a reason you're not using data|filter|autofilter (and dump the
worksheet_calculate event)???

Berry wrote:

Can anyone help me with this problem:

I use a code in my excel sheet to hide rows when there is a "0" (zero)
or a "C" is in a cell in the colomn. Now when I use my auto filter,
it's not filtering anything!

This is how my sheet lookslike:

1 C
1 H
2 M
2 T
3 K
3 H
4 0

This is how the code lookslike:

Dim X As Boolean

Private Sub Worksheet_Calculate()
Dim R As Long
If X = True Then Exit Sub
X = True
For R = 1 To Cells(65535, 3).End(xlUp).Row
Select Case Cells(R, 3).Value
Case "", 0, "C"
Me.Rows(R).Hidden = True
Case Else
Me.Rows(R).Hidden = False
End Select
Next
X = False
End Sub

What I want is to use the auto filter on the rows, but if I do this
now, the filter does not filter anything!

Who can help with this problem?

Greets, Berry


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel filter does not working anymore

Dave, the reason why I use the worksheet calculate event is because it
has to go automaticly!
I don't understand your question... What do I have to fill in by X??
I don't have so much experience with excel macro/code's.

This sheet is linked to another sheet, This sheet has to fill in
automaticly and is locked to change.
Do I have to fill in a new macro, or can I change something in it?

Thanx for your reply.
Greets

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel filter does not working anymore

Your code does this:
If X = True Then Exit Sub

How does X get set?

If it's only in your code, then after the first calculate, it'll be true.
You have
X = True
in the next line.

Maybe this should not be automatic.

Maybe just plopping a button on the worksheet that invokes the code would be
better?

Berry wrote:

Dave, the reason why I use the worksheet calculate event is because it
has to go automaticly!
I don't understand your question... What do I have to fill in by X??
I don't have so much experience with excel macro/code's.

This sheet is linked to another sheet, This sheet has to fill in
automaticly and is locked to change.
Do I have to fill in a new macro, or can I change something in it?

Thanx for your reply.
Greets


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel filter does not working anymore

The code activate now every time it is recalculating. And that is what
it has to do.

X is saying always I think.
The code have to calculate every time something is changing in column C

There can't be a button on the worksheet because it is been protected.

Berry



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel filter does not working anymore

Untested, but this might work:

Option Explicit
Private Sub Worksheet_Calculate()
Dim R As Long
Application.EnableEvents = False
For R = 1 To Cells(65535, 3).End(xlUp).Row
Select Case Cells(R, 3).Value
Case "", 0, "C"
Me.Rows(R).Hidden = True
Case Else
Me.Rows(R).Hidden = False
End Select
Next
Application.EnableEvents = True
End Sub


But if the worksheet is protected, you may have trouble in code, too.

Berry wrote:

The code activate now every time it is recalculating. And that is what
it has to do.

X is saying always I think.
The code have to calculate every time something is changing in column C

There can't be a button on the worksheet because it is been protected.

Berry


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel filter does not working anymore

Goodmorning,

This code is doing the same as my old one! He filter the rows contains
a "C" and a "0" out of the sheet, but I still can't filter.

I can sort ascending an descending with the autofilter. I have no idea
what's wrong.

Berry

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel filter does not working anymore

If the sheet is protected, then that could be the trouble.

Berry wrote:

Goodmorning,

This code is doing the same as my old one! He filter the rows contains
a "C" and a "0" out of the sheet, but I still can't filter.

I can sort ascending an descending with the autofilter. I have no idea
what's wrong.

Berry


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel filter does not working anymore

It is going to be protected, but now it isn't. It is not necessary to
protect the book. The most important now is the filter is going to
work. Maybe I need a code to use the autofilter in combination with the
code for hiding the rows.
The filter is filtering something but not what I ask to filter.

Greets




Dave Peterson schreef:

If the sheet is protected, then that could be the trouble.


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel filter does not working anymore

I don't have any more suggestions.

Sorry.

Berry wrote:

It is going to be protected, but now it isn't. It is not necessary to
protect the book. The most important now is the filter is going to
work. Maybe I need a code to use the autofilter in combination with the
code for hiding the rows.
The filter is filtering something but not what I ask to filter.

Greets

Dave Peterson schreef:

If the sheet is protected, then that could be the trouble.


--

Dave Peterson
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
Filter is not working anymore. Berry Excel Programming 0 June 13th 06 07:39 AM
VLOOKUP not working anymore Phil Excel Worksheet Functions 6 April 27th 06 07:40 PM
unselecting not working anymore? Joe Magiera Excel Discussion (Misc queries) 1 September 1st 05 03:35 AM
E-mail from VBA not working anymore ForSale[_29_] Excel Programming 4 August 12th 04 11:33 PM
it's not working anymore, please help! erin Excel Programming 4 February 14th 04 04:25 AM


All times are GMT +1. The time now is 12:29 AM.

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"