TaskMaster
Board Regular
- Joined
- Oct 15, 2020
- Messages
- 75
- Office Version
- 365
- 2016
- Platform
- Windows
Good morning,
I am have begun using power query to format my data which is working rather well. The issue is that the data source seems to change and im wondering if there would be to automate updating this using vba. E.g. "Framework_F7_Daily_Base" might become "Framework_F8_Daily_Base" when the source data is refreshed. My initial thought was to use an input box & find & replace to update the number that would change but I can't seem to get it working. Does any one have any suggestions?
I am have begun using power query to format my data which is working rather well. The issue is that the data source seems to change and im wondering if there would be to automate updating this using vba. E.g. "Framework_F7_Daily_Base" might become "Framework_F8_Daily_Base" when the source data is refreshed. My initial thought was to use an input box & find & replace to update the number that would change but I can't seem to get it working. Does any one have any suggestions?
VBA Code:
Sub UpdateLinks()
'***********************************************************************************
'Purpose: Update power query advanced editor with new source data
'How: Find and replace source data with new link
'Outputs: Using InputBox to manually enter new data link
'***********************************************************************************
Dim oQ As WorkbookQuery
Dim xy As Variant
Dim xx As Variant
'Manually enter the updated DB Link
xx = InputBox("Enter updated DB Link")
xy = ThisWorkbook.Worksheets("xxxx").Range("xxxx")
'Find queries using this table
For Each oQ In ActiveWorkbook.Queries
oQ.Formula = Replace(oQ.Formula,"Framework_" & xy"", xx"")
Next
End Sub
Power Query:
Source = AnalysisServices.Databases("SQLDB", [TypedMeasureColumns=true, Implementation="2.0"]),
Framework_F7_Daily_Base = Source{[Name="Framework_F7_Daily_Base"]}