Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array lookup type mismatch

Status
Not open for further replies.

Westicle

Programmer
Aug 22, 2002
29
0
0
GB
I'm getting a type mismatch (at the line with lookup function) in the following section of code:

Dim JobArray(1 To 85, 1 To 2) As String

Set JobSource = Worksheets("Data").Range("A:p")

'Populate the array with all the job numbers
x = 0
y = 1 'so the 1st cell looked at is A2, A1 has title.

Do While x < 85
x = x + 1
y = y + 1
JobArray(x, 1) = Worksheets("Data").Cells(y, 1) 'Job Number
JobArray(x, 2) = Worksheets("Data").Cells(y, 2) 'Job Name
Loop

For Each z In JobArray
If Application.WorksheetFunction.VLookup(JobArray(z, 1), JobSource, 16, False) = "All" Then
AnalCodesUF.JobNumberCB.AddItem
AnalCodesUF.JobNumberCB.List(0, 1) = ""
Else
End If
Next

any ideas?
 
For Each z In JobArray is not compatible with JobArray(z, 1)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I assume it's not compatible because they are both z. I do not know how to refer to each item in an array? Is there a keyword?
 
Why not do something like this ?
For x = 1 To 85
If Application.WorksheetFunction.VLookup(JobArray(x, 1), JobSource, 16, False) = "All" Then


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top