Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Why can't i filter two different columns with different criterias like this

Hi
Range("E4:AI183").Select
Selection.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
Selection.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False

It works without the third line.

I'm getting an error (1004) on the third line.

Regards,
Claus



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Why can't i filter two different columns with different criterias

Range("E4:AI183").Select
Selection.AutoFilter Field:=1, Criteria1:=Leverandor
Selection.AutoFilter Field:=35, Criteria1:="<"

be sure that the word Leverandor is a string variable with a value or wrap
it in quotes -- "Leverandor"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default Why can't i filter two different columns with different criterias like this

Claus

use the following code:

with Range("E4:AI183").
.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False
end with

DM Unseen

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Why can't i filter two different columns with different criterias

Hi Patrick

Leverandor is a string with a value. Thesecond line works fine alone

Claus

"Patrick Molloy" skrev i en
meddelelse ...
Range("E4:AI183").Select
Selection.AutoFilter Field:=1, Criteria1:=Leverandor
Selection.AutoFilter Field:=35, Criteria1:="<"

be sure that the word Leverandor is a string variable with a value or wrap
it in quotes -- "Leverandor"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Why can't i filter two different columns with different criterias like this

It works

Thank you

"DM Unseen" skrev i en meddelelse
ups.com...
Claus

use the following code:

with Range("E4:AI183").
.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False
end with

DM Unseen





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Why can't i filter two different columns with different criterias like this

Is there a way to check if the 2 crits. results in no rows ?

Leverandor contains Companys
and field 35 is the amount to be delivered.

Some Companys have no amount. I don't want to print these.

Claus

"Claus" skrev i en meddelelse
...
It works

Thank you

"DM Unseen" skrev i en meddelelse
ups.com...
Claus

use the following code:

with Range("E4:AI183").
.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False
end with

DM Unseen





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default Why can't i filter two different columns with different criterias like this

Dim bNoVisibleLines as boolean

with Range("E4:AI183").
.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False
bNoVisibleLines = (.SpecialCells(xlCellTypeVisible).Rows.Count = 1)
' only header ro shows
end with

Dm Unseen

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Why can't i filter two different columns with different criterias like this

Hi Unseen

I got i working, but:
bNoVisibleLines is always true when Count = 1, always false when count = 0
NumberOfVisibleLines is always x 5 of visible lines - 1 visible line = 5, 2
=10 an so on.

Why is NumberOfVisibleLines always = visiblerows * 5 ?


Dim bNoVisibleLines As Boolean, NumberOfVisibleLines As Integer
For y = 0 To AntalGyldigeLev - 1
Leverandor = Lev(y, 1)
bNoVisibleLines = False
NumberOfVisibleLines = 0
With Range("A4:AI183")
.AutoFilter Field:=5, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<", VisibleDropDown:=False
bNoVisibleLines = (.SpecialCells(xlCellTypeVisible).Rows.Count =
1)
NumberOfVisibleLines = .Rows.SpecialCells(xlCellTypeVisible).Count
End With
MsgBox Leverandor & ", " & NumberOfVisibleLines & " synlige linie(r)", ,
bNoVisibleLines
If y NumberOfVisibleLines 5 Then
'Call UdSkriv("Ordrebekræftigelse", Leverandor, "C", "D", "E", "F")
End If
Next y
"DM Unseen" skrev i en meddelelse
oups.com...
Dim bNoVisibleLines as boolean

with Range("E4:AI183").
.AutoFilter Field:=1, Criteria1:=Leverandor,
VisibleDropDown:=False
.AutoFilter Field:=35, Criteria1:="<",
VisibleDropDown:=False
bNoVisibleLines = (.SpecialCells(xlCellTypeVisible).Rows.Count = 1)
' only header ro shows
end with

Dm Unseen



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
how do sum a column only if meets the criterias of 2 columns Lorenzo Excel Discussion (Misc queries) 3 March 13th 08 04:34 PM
Filter data with two criterias Geo Excel Discussion (Misc queries) 5 October 1st 07 07:34 PM
Need function for one value for two criterias and two columns Melanie Excel Worksheet Functions 6 August 14th 06 05:38 AM
how to return the value of a cell based on two criterias in two columns devdutt_dev[_2_] Excel Programming 2 October 1st 04 03:33 AM
how to return the value of a cell based on two criterias in two columns devdutt_dev Excel Programming 2 October 1st 04 03:22 AM


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