Help with a macro please

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I'm running the following Macro that inserts a formula into a cell based on the population of another cell on the same sheet.
I need to edit the "Target, Range" to Sheet "Import", Cells B:B and can't get it figured out.

Any Help would be appreciated.

Thank you!




Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If Not Intersect[COLOR=#ff0000](Target, Range("B:B")[/COLOR]) Is Nothing Then
        Application.EnableEvents = False
        Target.Offset(, 2).Formula = "=IFERROR(VLOOKUP(Import!B2,Import!$B:$B,1,FALSE),0)"
        Application.EnableEvents = True
    End If
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
To get this to run against the "Import" sheet, you need to place this code in the "Import" Sheet Module.

Note that Worksheet_Change event procedures only work when they are placed in the proper sheet module (and by proper, I mean the sheet that you want to apply it to).
 
Upvote 0
What are you trying to do with that formula?
because all it will do is return the value in B2 everytime.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

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