VBA Code for Index Match to return values only - Not Formula

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,500
Office Version
  1. 2016
Platform
  1. Windows
Hello Friends,

How can this formula be written in a VBA code to return results only - not formula

=INDEX(suppliers,MATCH(B11,ref,0))

suppliers & ref are named ranges within the worksheet

I want the it to be applied to C11:C77

Any help would be appreciated.

Regards,

Humayun
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
How about
VBA Code:
With Range("C11:C77")
   .Formula = "=INDEX(suppliers,MATCH(B11,ref,0))"
   .Value = .Value
End With
 
Upvote 0
Solution
Thanks fluff,

Your solution is working just perfect

Is the below way of adding another range is correct - it is working fine though

VBA Code:
Sub hello()

With Range("E1:E5")
   .Formula = "=INDEX(suppliers,MATCH(D1,ref,0))"
    .Value = .Value
   End With
   
  With Range("F1:F5")
  .Formula = "=INDEX(customers,MATCH(D1,ref,0))"
   .Value = .Value
End With

End Sub

or can it be shorten ??

Regards,

Humayun
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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