Xlookup with VBA but for the selected table row only

lifezhwy

New Member
Joined
Jul 21, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Is there an easy way to run the macro either for the selected table row only, or only for the rows where the lookup value is not blank?

What I am trying to do is that if I select PPM ID (from a drop-down list) the code runs and populates Level 0 (leveraging xLookup), but if I leave PPM ID blank, the code doesn't run for that row and doesn't overwrite Level ) column.

image



Here is the code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("Tbl_Input_DB[PPM ID]")) Is Nothing Then

Call Copy_v1

End If

End Sub


Sub Copy_v1()

With Range("Tbl_Input_DB[Level 0]")

.Formula = "=XLOOKUP([@[PPM ID]],Q_BOW_LCM[PPM ID],Q_BOW_LCM[Pillar],"""")"

.Value = .Value

End With

Many thanks in advance!

@Fluff thank you for your earlier suggestion, any help would be appreciated.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

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