Unable to get the Match property of the WorksheetFunction class

BoyBoy

New Member
Joined
Sep 25, 2020
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello,
I was trying to run the following code:

Set e = Sheets("Sheet1")
Set i = Sheets("Sheet2")

Dim d
Dim j
d = 1
j = 2

Do Until IsEmpty(e.Range("CH" & j))

If e.Range("CH" & j) <> "" Then
d = d + 1
e.Cells(d, 3).Value = "VI"

e.Cells(d, 4).Value = Application.WorksheetFunction.Index(i.Range("F:F"), Application.WorksheetFunction.Match(Cells(j, 84).Value, i.Range("N:N"), 0))
e.Cells(d, 4).Value = e.Cells(d, 4).Value
e.Cells(d, 5).Value = Application.WorksheetFunction.Index(i.Range("E:E"), Application.WorksheetFunction.Match(Cells(j, 84).Value, i.Range("N:N"), 0))
e.Cells(d, 5).Value = e.Cells(d, 5).Value
If e.Cells(d, 8).Value = Application.WorksheetFunction.Index(i.Range("G:G"), Application.WorksheetFunction.Match(Cells(j, 84).Value, i.Range("N:N"), 0)) = "" Then
e.Cells(d, 8).Value = ""
Else: e.Cells(d, 8).Value = Application.WorksheetFunction.Index(i.Range("G:G"), Application.WorksheetFunction.Match(Cells(j, 84).Value, i.Range("N:N"), 0))
e.Cells(d, 8).Value = e.Cells(d, 8).Value
End If
If e.Cells(d, 8).Value = "" Then
e.Cells(d, 10).Value = ""
Else: e.Cells(d, 10).Value = e.Cells(d, 8).Value - Weekday(e.Cells(d, 8).Value, 3) + 2
e.Cells(d, 10).Value = e.Cells(d, 10).Value
End If

End If
j = j + 1
Loop

End Sub

But received this error
1604634912858.png

Can anyone please advise what's wrong with my Index & Match function above?
Thanks in advance.

Boyboy
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
What do you get with
VBA Code:
Sub ddddd()
    Set e = Sheets("Sheet1")
    Set i = Sheets("Sheet2")

    Dim d
    Dim j
    d = 1
    j = 2

    Do Until IsEmpty(e.Range("CH" & j))

        If e.Range("CH" & j) <> "" Then
            d = d + 1
            e.Cells(d, 3).Value = "VI"

            e.Cells(d, 4).Value = Application.Index(i.Range("F:F"), Application.Match(e.Cells(j, 84).Value, i.Range("N:N"), 0))
            e.Cells(d, 4).Value = e.Cells(d, 4).Value
            e.Cells(d, 5).Value = Application.Index(i.Range("E:E"), Application.Match(e.Cells(j, 84).Value, i.Range("N:N"), 0))
            e.Cells(d, 5).Value = e.Cells(d, 5).Value
            If e.Cells(d, 8).Value = Application.Index(i.Range("G:G"), Application.Match(e.Cells(j, 84).Value, i.Range("N:N"), 0)) = "" Then
                e.Cells(d, 8).Value = ""
            Else: e.Cells(d, 8).Value = Application.Index(i.Range("G:G"), Application.Match(e.Cells(j, 84).Value, i.Range("N:N"), 0))
                e.Cells(d, 8).Value = e.Cells(d, 8).Value
            End If
            If e.Cells(d, 8).Value = "" Then
                e.Cells(d, 10).Value = ""
            Else: e.Cells(d, 10).Value = e.Cells(d, 8).Value - Weekday(e.Cells(d, 8).Value, 3) + 2
                e.Cells(d, 10).Value = e.Cells(d, 10).Value
            End If

        End If
        j = j + 1
    Loop

End Sub
 
Upvote 0
now I am getting
1604640850179.png


1604640941394.png

also cell E2 & D2 both returning error value, which should not be
1604641371004.png
 

Attachments

  • 1604641310463.png
    1604641310463.png
    2.1 KB · Views: 2
Upvote 0
That line of yours makes no sense as you are trying to test 2 conditions without either an And or an Or.
If you are getting #N/A as a result then you need to step through your code using F8 and see exactly what the Values of your cells are as you step through.
 
Upvote 0
Thanks so much, I have another urgent project to finish, will review my code later.
Have a great night!
BoyBoy
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top