Running an Event Handling Macro

helpneeded04

New Member
Joined
Jun 9, 2015
Messages
9
Hello,
I have a query pulling in data from an external database. In the same worksheet, I have cells equaling cells in the query table. When data in the query changes, the equals formulas #ref out. I am trying to create a macro that will copy the formulas down whenever the query table is refreshed. I have the following in a worksheet object. However, when I try to run the macro, it does not show up in the macro list. Any help would be much appreciated.

Private Sub Worksheet_QueryTableRefresh(ByVal Target As QueryTable)
Range("F2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Range("F2").Select
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Private subs don't appear in the macro list. Just remove the "Private".
 
Upvote 0
That code will be triggered when the query is refreshed.

It won't appear on the macro list because it's passed an argument, Target, which is the query table that's been refreshed.

If you want to run the code manually put it in a sub in a standard module and remove the argument.
 
Upvote 0
That code will be triggered when the query is refreshed.

It won't appear on the macro list because it's passed an argument, Target, which is the query table that's been refreshed.

If you want to run the code manually put it in a sub in a standard module and remove the argument.

Hi Norie,

This code was not triggered when the query is refreshed.

Thank you
 
Upvote 0
Hi Norie,

This code was not triggered when the query is refreshed.

Thank you
Where did you get the code you posted in your initial post? I'm not familiar with a worksheet event called:

Worksheet_QueryTableRefresh
 
Upvote 0
When do you want this code to be run?
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

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