Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can i use IsEmpty and IF this way? What's wrong here?


Hi all!
i have a code looks like this:



code:
--------------------------------------------------------------------------------
Sub criteria()
Dim arr As Variant
Dim i As Integer
Dim j As Integer
'put the criteria into an array
Set arr = Range("A38042:E38168")
Range("E1").Select
For i = 1 To 10
If IsEmpty(arr.Cells(i, 2) And arr.Cells(i, 3)) = False Then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2)
Operator:=xlAnd, Criteria2:=arr(i, 3)
Cells(38041 + j, 6 + i).Value = Range("F38039")
End If
Next i
End Sub
--------------------------------------------------------------------------------




what i am trying to do is :
if the 2nd col and 3rd col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2), Operator:=xlAnd
Criteria2:=arr(i, 3)
Else if
if the 4th col and 5th col(of arr) is not empty then
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4), Operator:=xlAnd
Criteria2:=arr(i, 5)
ElseIf
if the 3th col and 4th col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 3)
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4)
ElseIf
if the 1st col and 5th col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 1)
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 5)



what's wrong with my IF there

--
changeabl
-----------------------------------------------------------------------
changeable's Profile: http://www.excelforum.com/member.php...fo&userid=1571
View this thread: http://www.excelforum.com/showthread.php?threadid=27452

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can i use IsEmpty and IF this way? What's wrong here?

If IsEmpty(arr.Cells(i, 2) And arr.Cells(i, 3)) = False Then

would be

If Not (IsEmpty(arr.Cells(i, 2)) And IsEmpty(arr.Cells(i, 3))) Then

--
Regards,
Tom Ogilvy

"changeable" wrote in message
...

Hi all!
i have a code looks like this:



code:
--------------------------------------------------------------------------

------
Sub criteria()
Dim arr As Variant
Dim i As Integer
Dim j As Integer
'put the criteria into an array
Set arr = Range("A38042:E38168")
Range("E1").Select
For i = 1 To 10
If IsEmpty(arr.Cells(i, 2) And arr.Cells(i, 3)) = False Then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2),
Operator:=xlAnd, Criteria2:=arr(i, 3)
Cells(38041 + j, 6 + i).Value = Range("F38039")
End If
Next i
End Sub
--------------------------------------------------------------------------

------




what i am trying to do is :
if the 2nd col and 3rd col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2), Operator:=xlAnd,
Criteria2:=arr(i, 3)
Else if
if the 4th col and 5th col(of arr) is not empty then
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4), Operator:=xlAnd,
Criteria2:=arr(i, 5)
ElseIf
if the 3th col and 4th col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 3)
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4)
ElseIf
if the 1st col and 5th col(of arr) is not empty then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 1)
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 5)



what's wrong with my IF there?


--
changeable
------------------------------------------------------------------------
changeable's Profile:

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



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
IsEmpty on a range/array Norman Jones Excel Programming 3 September 7th 04 08:35 PM
Do.....Loop until IsEmpty(....) helmekki[_8_] Excel Programming 2 June 7th 04 03:15 PM
Help with IsEmpty Fred Excel Programming 1 February 10th 04 03:12 PM
isempty mike allen Excel Programming 2 January 3rd 04 10:45 PM
vba: isempty chick-racer[_37_] Excel Programming 3 November 17th 03 09:52 PM


All times are GMT +1. The time now is 08:30 PM.

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"