Trying to use Index with Match but I get error code 2042

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
774
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a data based on sheet 'ACTIVITY' and the code am using is in Column D. by references is on the worksheet 'State Country Code'.

I tried using this formula and it doesn't seem to work. I get an error code 2042

Any assistance will greatly be appreciated.

Thank you,

Excel Formula:
=INDEX('State Country Code'!A2:A10387,MATCH(ACTIVITY!D2,'State Country Code'!B2:B10387,0))
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Code looks ok. Can you provide sample data using XL2BB so that we can test.
 
Upvote 0
I have a data based on sheet 'ACTIVITY' and the code am using is in Column D. by references is on the worksheet 'State Country Code'.

I tried using this formula and it doesn't seem to work. I get an error code 2042

Any assistance will greatly be appreciated.

Thank you,

Excel Formula:
=INDEX('State Country Code'!A2:A10387,MATCH(ACTIVITY!D2,'State Country Code'!B2:B10387,0))
Thank you, here is a link into the Drop Box. While you're there why does the day Column N converts it to a true value after I plug in the date. However, for now my main concern is for my original question.



Thank you again.
 
Upvote 0
Your workbook has a change event on that sheet that will convert any formula you try to put in that sheet from columns A-M to a value.
In this case the formula appears to be back to front and returning #N/A and VBA is converting that to Error 2042 which the code is then Upper Casing.

I expect the formula should be:
(with columns A & B for Index & Match respectively reversed to B & A and row range locked down)
Excel Formula:
=INDEX('State Country Code'!B$2:B$10387,MATCH(ACTIVITY!D2,'State Country Code'!A$2:A$10387,0))

I am not sure this will fully solve your issue without addressing how you are entering the formula and what your change macro is doing.
It doesn't make sense to me to format the whole of Columns A-M for all rows each time there is a change in any column.

PS: I don't understand your issue with column N. You have prepopulated it with a formula and the change event in the sample you sent doesn't impact it since it only goes up to the Column M. The formula appears to be doing what it is intended to do.
The formula being: =IF(A7="","",DAY(A7))
 
Upvote 0
Once again:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,157
Messages
6,170,418
Members
452,325
Latest member
BlahQz

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