VBA to fill formula

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi all!

I am in need of code that will fill in the below formula in E7:E5000 with a deactivate event.
=IFERROR(INDEX(Instruments!$C$3:$C$40,MATCH(B7,Instruments!$B$3:$B$40,0)),0)

Thank you!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What do you mean by Deactivate event....

but this will populate the required range

Code:
Range("E7:E5000").formula="=IFERROR(INDEX(Instruments!$C$3:$C$40,MATCH(B7,Instruments!$B$3:$B$40,0)),0)"
 
Upvote 0
Hi Mike

When leaving the sheet the macro will run. I was able figure that part out.

Works great!

Thank you!
 
Upvote 0
Hi Mike
How can I add another range like below but doesn't work?

Code:
Private Sub Worksheet_Deactivate()
ThisWorkbook.Sheets("Patch By Universe").Application.Calculation = xlManual
Range("E7:E5000").Formula = "=IFERROR(INDEX(Instruments!$C$3:$C$40,MATCH(B7,Instruments!$B$3:$B$40,0)),0)"
Range("F7:F5000").Formula = "=IF(E7=120,D7/120,IF(E7=208,D7/208,""))"


ThisWorkbook.Sheets("Instruments").Calculate

End Sub
 
Upvote 0
Is it erroring out and if yes is it on the line before the formulas?
You also need to double the quotes where you have ""
 
Upvote 0
How about
Code:
Range("E7:E5000").FormulaR1C1= "=IFERROR(VLOOKUP(RC[-3], Instruments!R3C2:R40C3, 2, False), 0)"
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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