ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why can't i filter two different columns with different criterias like this (https://www.excelbanter.com/excel-programming/339379-why-cant-i-filter-two-different-columns-different-criterias-like.html)

Claus[_3_]

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




Patrick Molloy[_2_]

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"

DM Unseen

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


Claus[_3_]

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"




Claus[_3_]

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




Claus[_3_]

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






DM Unseen

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


Claus[_3_]

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





All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com