Convert a formula to VBA code

sofas

Active Member
Joined
Sep 11, 2022
Messages
478
Office Version
  1. 2019
Platform
  1. Windows
Welcome. I have this formula that I want to convert into code. VBA It is executed starting from cell C6 along the column, and when there is no value in column A, the cell remains empty. Thank you in advance

=INDEX($B$2:$D$6, MATCH(A10,$A$2:$A$6,0), MATCH(B10, $B$1:$D$1, 0))
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
If you are looking for specific code, then provide some sample data as VBA is not generic. 8-10 records and a mocked up solution. Use XL2bb as we cannot manipulate data in a picture. So no pictures. Show all ranges/tables in XL2BB
 
Upvote 0
If you are looking for specific code, then provide some sample data as VBA is not generic. 8-10 records and a mocked up solution. Use XL2bb as we cannot manipulate data in a picture. So no pictures. Show all ranges/tables in XL2BB
Sorry.........The file was uploaded to another site because I did not know how to upload files on the forum

 
Upvote 0
Test this with a copy of your worksheet.

VBA Code:
Sub Insert_Formula()
  With Range("C10:C" & Range("A" & Rows.Count).End(xlUp).Row)
    .Formula = "=IFNA(INDEX(B$2:D$6,MATCH(A10,A$2:A$6,0),MATCH(B10,B$1:D$1,0)),"""")"
  End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,402
Messages
6,124,708
Members
449,182
Latest member
mrlanc20

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