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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
What sheet is Cells(j, 84) on and it that sheet the active sheet?
 
Upvote 0
and was Sheet1 the active sheet when the code was run?
 
Upvote 0
Ok, what happens with code below? do you get the same error?

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.WorksheetFunction.Index(i.Range("F:F"), Application.WorksheetFunction.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.WorksheetFunction.Index(i.Range("E:E"), Application.WorksheetFunction.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.WorksheetFunction.Index(i.Range("G:G"), Application.WorksheetFunction.Match(e.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(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

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

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