sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
I have the code below that refreshes a Power Query Editor generated table and then does some things to the table. The problem I have is when the code is run, it returns the table back to it's refreshed state without my changes that I made, even though the refresh is the first line of the code. How can I stop it from refreshing when the changes are made? Thanks, SS
VBA Code:
Sub Update_TBL_List()
'
' Update TBL_List Macro
'
'
With Application
.EnableEvents = False
.ScreenUpdating = False
.CutCopyMode = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
Worksheets("Table Quick Access").ListObjects("TBL_List").Refresh
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Value2 = "Table File Path"
Range("C1").Value2 = "Table Name"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Application.Calculation = xlAutomatic
Range("B2").Select
ActiveCell.Formula2R1C1 = _
"=IFERROR(MID(CELL(""address"",INDIRECT([@[Table Name]])),SEARCH("".xlsm]"",CELL(""address"",INDIRECT([@[Table Name]])),1)+6,(SEARCH(""'!$"",CELL(""address"",INDIRECT([@[Table Name]])),1)-(SEARCH("".xlsm]"",CELL(""address"",INDIRECT([@[Table Name]])),1)+6))),""Table Quick Access"")"
Range("A2").Select
ActiveCell.Formula2R1C1 = "=CELL(""address"",INDIRECT([@[Table Name]]))"
Range("A2").Select
Selection.AutoFill Destination:=Range("TBL_List[Table File Path]"), Type:= _
xlFillDefault
Columns("A:A").ColumnWidth = 64
Columns("B:C").ColumnWidth = 32
Columns("D:E").ColumnWidth = 12
With Application
.EnableEvents = True
.ScreenUpdating = True
.CutCopyMode = False
.DisplayAlerts = False
' .Calculation = xlAutomatic
End With
End Sub