Insert Formula in Macro

MJA001

New Member
Joined
Dec 28, 2017
Messages
28
I'd like to insert the formula that does a great Index Match job for me. But I'd like to automate it now and can't figure out how.

INDEX(Project2!B:B, MATCH(Project!A:A,Project2!G:G,0))

So in my Workbook, I'd like this Matches from the formula to be displayed in column BJ of Worksheet "Project" .


Thanks in advance for any help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
There is only one look up value and I couldn't discern from the article to apply it to use in a Macro.

In simpler terms, the formula matches the data from worksheet "project", column A to the same data from Worksheet "Project2" column G. Then it indexes the match to populate the data from worksheet "Project2", Column B into the corresponding cells in worksheet "Project" column BJ.

So it should work, but I'm lost as to converting the formula into a macro.
 
Upvote 0
MATCH(Project!A:A,Project2!G:G,0) is wrong if you are only trying to lookup a single value ... Project!A:A probably just grabs whatever value is in A1.

This would be valid:

MATCH(Project!A2,Project2!G:G,0)

that would return the first row number that A2 matches in column G
 
Last edited:
Upvote 0
Cerfani,

Thanks for the info, but I don't I'm doing a good job of communicating. I do not want to match a single value. I need the macro to look through all the cells, find the matches and display the corresponding value. The formula works great for this.

When I record a macro of myself adding it to a single cell, the formula =INDEX(Project2!B:B, MATCH(Project!A:A,Project2!G:G,0))

is changed into this: "=INDEX(Project2!C[-60], MATCH(Project!C[-61],Project2!C[-55],0))"


I can't figure out how to add it into a macro and apply to the entire column. Any suggestions?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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