Call and filter

Marcel2586

Registered User.
Local time
Today, 05:17
Joined
Mar 1, 2012
Messages
41
Hello,

My code works partialy.

As soon as it hits Call test("060C") i get a runtime error 13
Type mismatch. What am i dowing wrong.

:banghead:

Code:
  Sub test(wc As Integer)
 
  Sheets("Print vriendelijk").Select
    ActiveSheet.Range("F2").AutoFilter Field:=6, Criteria1:="" & wc, _
    Operator:=xlAnd
 
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
 
    Selection.Copy
 
    Sheets("Sorted").Select
    Range("A65536").End(xlUp).Offset(1).Select
    ActiveSheet.Paste
 
End Sub
 
Sub look()
Call test(2600)
Call test(2700)
Call test(1700)
Call test(1100)
Call test("060C")
Call test("060M")
Call test("060R")
Call test("060S")
Call test(1400)
Call test(1401)
Call test(1450)
Call test(1460)
Call test(1461)
Call test(1501)
Call test(1600)
Call test(1800)
Call test(1900)
Call test(2400)
Call test(2450)
Call test(2300)
Call test(2800)
Call test(2850)
Call test(2900)
Call test(2900DK)
Call test(3608)
Call test(3650)
 
End Sub
 
What is the code for Test? It looks like it is expecting a number but is getting text instead. So how is the code written?
 
What is the code for Test? It looks like it is expecting a number but is getting text instead. So how is the code written?

boblarson,

the code for test is above the sub look

Code:
Sub test(wc As Integer)
 
  Sheets("Print vriendelijk").Select
    ActiveSheet.Range("F2").AutoFilter Field:=6, Criteria1:="" & wc, _
    Operator:=xlAnd
 
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
 
    Selection.Copy
 
    Sheets("Sorted").Select
    Range("A65536").End(xlUp).Offset(1).Select
    ActiveSheet.Paste
 
End Sub

Column 6 are department codes who have sent parts for repair. We need to keep track of them. i group and filter them by hand but the list of departments is large and you can make easily mistakes. What I do is filter column 6 from call test (department code) where sub test kicks in and copy from the filtered department code and paste it to a new sheet.
I have changed column 6 to a text format but that did not help.
.
 
Your problem is the part in red:

Sub test(wc As Integer)

You are fine until you try to pass text to it: "060C" as that is NOT an Integer.

Try changing it to Variant instead of Integer.
 
Your problem is the part in red:

Sub test(wc As Integer)

You are fine until you try to pass text to it: "060C" as that is NOT an Integer.

Try changing it to Variant instead of Integer.

Thank you sir
 

Users who are viewing this thread

Back
Top Bottom