Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using Criteria with two possible values


its for deleting rows with that text in the column. it looks like this
Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="not in system"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

So, will this work?

Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="=not in system", _
Operator:=xlOr, _
Criteria2:="=NOT OKC"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

or do I need a Field:=2 before the second criteri

--
DK
-----------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...fo&userid=1451
View this thread: http://www.excelforum.com/showthread.php?threadid=27563

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default using Criteria with two possible values

Hi DKY

the Field:=1
means the first field in your data area
so, no, from what i can see you're okay.

but why don't you record a macro doing exactly this (using CUSTOM to choose
both criteria - make sure you populate all four boxes and choose OR as the
comparison operator) and see the code which is generated.

Cheers
JulieD

"DKY" wrote in message
...

its for deleting rows with that text in the column. it looks like this
Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="not in system"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

So, will this work?

Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="=not in system", _
Operator:=xlOr, _
Criteria2:="=NOT OKC"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

or do I need a Field:=2 before the second criteria


--
DKY
------------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=275631



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default using Criteria with two possible values

DKY,

Yes, your code should work as modified.
No, you don't need a Field2 for the second criteria.

HTH,
Bernie
MS Excel MVP

"DKY" wrote in message
...

its for deleting rows with that text in the column. it looks like this
Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="not in system"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

So, will this work?

Dim rng As Range, rng1 As Range
Range("J:J").AutoFilter _
Field:=1, Criteria1:="=not in system", _
Operator:=xlOr, _
Criteria2:="=NOT OKC"
On Error Resume Next
Set rng1 = Range("J2:J65536").SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
Range("J1").CurrentRegion.AutoFilter

or do I need a Field:=2 before the second criteria


--
DKY
------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=275631



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
Sum of values based on different criteria Irene Excel Discussion (Misc queries) 4 November 19th 08 11:17 PM
Looking up values with multiple criteria CodyT Excel Worksheet Functions 1 June 24th 08 11:14 PM
one criteria/mult. values cherrynich Excel Worksheet Functions 1 April 17th 06 11:42 PM
using Criteria with two possible values DKY[_21_] Excel Programming 4 November 5th 04 03:45 PM


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