Add formula after index, match

chunu

Board Regular
Joined
Jul 5, 2012
Messages
109
Office Version
  1. 2013
Platform
  1. Windows
  2. Mobile
Hi friends,

is it possible to add formula after index match in vba , in normal index match its working but not with vba.

vba code
Code:
Sub lookup()      lastrow = Cells(Rows.Count, "e").End(xlUp).Row
   For i = 2 To lastrow
      Range("e" & i) = Range("b" & Application.Match(Cells(i, 4), Range("a2:a" & lastrow), 0) + 1)
      Next
   End Sub

Normal index match
Code:
=INDEX(B10:B12,MATCH(D10,A10:A12,0))*G10-H10*G10

i want to add last part of normal index match (*G10-H10*G10)

Thanks





25i6otz.png
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
How about
Code:
Range("e" & i) = Range("b" & Application.Match(Cells(i, 4), Range("a2:a" & LastRow), 0) + 1) * Range("G" & i) - Range("H" & i) * Range("G" & i)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hi,
sorry to bother you,
how to use this formula to get value from another workbook.

Thanks

How about
Code:
Range("e" & i) = Range("b" & Application.Match(Cells(i, 4), Range("a2:a" & LastRow), 0) + 1) * Range("G" & i) - Range("H" & i) * Range("G" & i)
 
Upvote 0
You would need to specify the workbook & worksheet with the ranges
 
Upvote 0
You would need to specify the workbook & worksheet with the ranges

Thank you for your help, got the result.

Code:
Range("l" & i) = Application.Workbooks("data.xlsm").Worksheets("product").Range("e" & Application.Match(Cells(i, 6), Application.Workbooks("data.xlsm").Worksheets("product").Range("a2:a" & lastrow), 0) + 1) * Range("e" & i) - Range("j" & i) * Range("e" & i)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

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