VBA to fill formula

Russk68

Well-known Member
Joined
May 1, 2006
Messages
596
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

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