RUN time error 1004 - Unable to match the property

Status
Not open for further replies.

Murtuz

New Member
Joined
Feb 11, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Running below code and getting "1004" error "Unable to match the property".

I have below coding to match the headings from a sheet and paste the data in different sheet under same heading. but when it does not find exact match it get stuck at yellow highlighted code.

I just need it to skip the mismatched heading and search for next column heading and paste the data under it.

Kindly help!

VBA Code:
Sub CopyHeaders()

LastRow1 = ThisWorkbook.Worksheets("Headers").Range("A" & Rows.Count).End(xlUp).Row
LastRow2 = ThisWorkbook.Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To LastRow1

Set Rng1 = ThisWorkbook.Worksheets("Sheet1").Range("A1:AJ1")
Set Rng2 = ThisWorkbook.Worksheets("Sheet2").Range("A1:AJ1")

[COLOR=rgb(251, 160, 38)]m = Application.WorksheetFunction.Match(ThisWorkbook.Worksheets("Headers").Range("A" & i).Value, Rng1, 0)[/COLOR]

ThisWorkbook.Worksheets("Sheet1").Range("A2:A" & LastRow2).Columns(m).Copy


h = Application.WorksheetFunction.Match(ThisWorkbook.Worksheets("Headers").Range("A" & i).Value, Rng2, 0)

ThisWorkbook.Worksheets("Sheet2").Range("A2").Columns(h).PasteSpecial xlPasteValues

Next i

MsgBox "Data has been pasted successfully"

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Duplicate to: Error 1004- Unable to get the matched property

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread since the later one already has a reply so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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