Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Using AutoFilter from VBA

I want to show data rows based on 2 conditions using OR not AND.

I want to show a row if it has a value in Field 14

OR

If it has no value in Field 12 AND a value in Field 16

I have some code that filters on one Field but I am having trouble making the
OR working.

Any way to do that ? Any help appreciated.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,872
Default Using AutoFilter from VBA

Hi,

Am 24 Jun 2014 13:33:58 GMT schrieb Isis:

I want to show data rows based on 2 conditions using OR not AND.

I want to show a row if it has a value in Field 14

OR

If it has no value in Field 12 AND a value in Field 16


try:

Sub HideRows()
Dim LRow As Long
Dim rngC As Range

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In .Range("P2:P" & LRow)
If Len(rngC) = 0 And Len(rngC.Offset(, -4)) 0 _
Or Len(rngC.Offset(, -2)) = 0 Then
.Rows(rngC.Row).Hidden = True
End If
Next
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,045
Default Using AutoFilter from VBA

On 24 Jun 2014 13:33:58 GMT, Isis wrote:

I want to show data rows based on 2 conditions using OR not AND.

I want to show a row if it has a value in Field 14

OR

If it has no value in Field 12 AND a value in Field 16

I have some code that filters on one Field but I am having trouble making the
OR working.

Any way to do that ? Any help appreciated.

Thanks


I don't think you can do that with AutoFilter. I think you have to use Advanced Filter. This will require setting up a criteria range on a worksheet.
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 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 07:19 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"