1004 error. unable to get the Match property of the WorksheetFunction class.

eugenewong

New Member
Joined
Jul 28, 2011
Messages
2
Hi

I'm currently trying to obtain data from the user from first sheet1 and then do the following tasks:
1) vlookup some values from sheet2 (which is successful i guess)
2) find the string given in sheet1 in sheet2 and change the value in the next column in sheet2 (i'm sorry for the lousy description but i hope u get the idea)

i can't seem to get the 2nd part working. Can somebody help me? it gives me the error "1004, unable to get the Match property of the WorksheetFunction class"

Code:
Sub findReplace()
    
    Dim i As Long, j As Long, LR As Long
    Dim dataRow As Long
    
     LR = Cells(Rows.Count, 1).End(xlUp).row
     
        
        For j = 2 To LR
            Sheets("sheet1").Cells(j, 2) = Application.VLookup(Sheets("sheet1").Cells(j, 1), Sheets("Sheet2").Columns("b:e"), 2, False)
            Sheets("sheet1").Cells(j, 3) = Application.VLookup(Sheets("sheet1").Cells(j, 1), Sheets("Sheet2").Columns("b:e"), 3, False)
        
        Next j
      
        
        For i = 2 To LR
        
            dataRow = Application.WorksheetFunction.Match(Sheets("sheet1").Cells(i, 1), Sheets("sheet2").Range("b1:b100"), 0)
    
            Sheets("sheet2").Cells(dataRow, 3) = Cells(dataRow, 3) - 1
    
        Next i
    
End Sub

Any help is greatly appreciated and do correct me if i did anything wrong as i'm still new to VB. thanks!
 

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.
Hi

I'm currently trying to obtain data from the user from first sheet1 and then do the following tasks:
1) vlookup some values from sheet2 (which is successful i guess)
2) find the string given in sheet1 in sheet2 and change the value in the next column in sheet2 (i'm sorry for the lousy description but i hope u get the idea)

i can't seem to get the 2nd part working. Can somebody help me? it gives me the error "1004, unable to get the Match property of the WorksheetFunction class"

Code:
Sub findReplace()
 
    Dim i As Long, j As Long, LR As Long
    Dim dataRow As Long
 
     LR = Cells(Rows.Count, 1).End(xlUp).row
 
 
        For j = 2 To LR
            Sheets("sheet1").Cells(j, 2) = Application.VLookup(Sheets("sheet1").Cells(j, 1), Sheets("Sheet2").Columns("b:e"), 2, False)
            Sheets("sheet1").Cells(j, 3) = Application.VLookup(Sheets("sheet1").Cells(j, 1), Sheets("Sheet2").Columns("b:e"), 3, False)
 
        Next j
 
 
        For i = 2 To LR
           [COLOR=red]With WorksheetFunction.Application[/COLOR]
            dataRow = .Match(Sheets("sheet1").Cells(i, 1), Sheets("sheet2").Range("b1:b100"), 0)
 
            Sheets("sheet2").Cells(dataRow, 3) = Cells(dataRow, 3) - 1
            [COLOR=red]End With[/COLOR]
        Next i
 
End Sub

Any help is greatly appreciated and do correct me if i did anything wrong as i'm still new to VB. thanks!

Try something like this (in red) I usually do it when I get the same Error...
 
Upvote 0
I still get the same error. Is there something wrong with my LR?
it was intended to loop until the last row with a string entered by the user.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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