Update cell based of powerquery result

chircop

New Member
Joined
Oct 18, 2019
Messages
1
I have a button to update a powerquery on Sheet 2 from another workbook. the number of rows of data will vary.
Now i want to include VB script on the button to update data on Sheet1 based off the data imported.

What I am trying to accomplish.
if Sheet2 column A has an entry that MATCHES Sheet1 column I (a calculated value if that matters)

use the corresponding data in sheet 2 column B to change the data in Sheet1 Column F

if Sheet2 column B = 5 change Sheet1 Column F to "Y"
if Sheet2 column B = 30 change Sheet1 Column F to "NONE"
if Sheet2 column B = (any other number) change Sheet1 Column F to "N"
Incidentally, i don't want any of the data changing if the Sheet2 column B does not match Sheet 1 Column F


Sample Data Sheet 1

[TABLE="width: 319"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD][TABLE="width: 319"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column F[/TD]
[TD]Column I (calculated resulting value)[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 1[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 2[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 3[/TD]
[/TR]
[TR]
[TD]NONE[/TD]
[TD]Test Data 4[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 5[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 6[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 7[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 8[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 9[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2 Sample Data
[TABLE="width: 156"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]Test Data 1[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]Test Data 3[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD]Test Data 4[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]Test Data 6[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD]Test Data 7[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD]Test Data 9[/TD]
[TD="align: right"]5[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 1 desired result

[TABLE="width: 319"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column F[/TD]
[TD]Column I (calculated resulting value)[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 1[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 2[/TD]
[/TR]
[TR]
[TD]NONE[/TD]
[TD]Test Data 3[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 4[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 5[/TD]
[/TR]
[TR]
[TD]NONE[/TD]
[TD]Test Data 6[/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]Test Data 7[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 8[/TD]
[/TR]
[TR]
[TD]Y[/TD]
[TD]Test Data 9[/TD]
[/TR]
</tbody>[/TABLE]

I know the logic just cannot figure out the best way to code it. Any assistance is appreciated.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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