Power query - stopping refresh if no data available

Kariba

Board Regular
Joined
Mar 15, 2023
Messages
59
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a master workbook of data which I update three times a week with a rolling 30-day data file I receive.
The data is from 3 days ahead to 33 days ahead.
I then use power queries in multiple other workbooks to pull latest data over from that master file.
Column A is the date of latest update I received. Column B is the date of between 3 and 33 days ahead.
The power query then finds the latest info from column A and column B

However, we've just taken on someone new who unfortunately despite best efforts keeps refreshing data for days 1 & 2. As there is no data so no match for those days, the power query wipes out all existing data and then all the lookups, conditional formatting etc in the workbooks gets adjusted automatically.

I can't find any way to prevent a refresh if no data is found.

Anyone know how to do this if it's even possible?

Last update Start of data file
1729234795831.png
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Generically speaking, there is a “try….otherwise….” Pattern that may be helpful. If the try step throws an error, the otherwise step kicks in. Maybe you could create 2 queries with the first throwing an error if there is no data you need. Just an idea.
 
Upvote 0
Tried this and seems to work so far

If Range("C11").Value >= Date + 3 Then
Range("C11").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Else
MsgBox "Not refreshed", vbCritical, "Warning"
 
Upvote 0

Forum statistics

Threads
1,222,759
Messages
6,168,052
Members
452,160
Latest member
Bekerinik

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