Attribute VB_Name = "FixQueryConnections" Option Explicit Public Sub SetQueryConnections() Dim slNewConnectionName As String slNewConnectionName = InputBox("Please enter the new connection name.", "Set All Query Connections") If slNewConnectionName = "" Then Exit Sub End If Dim olSheet As Excel.Worksheet Dim olQuery As Excel.QueryTable Dim ilTotalUpdated As Integer For Each olSheet In ThisWorkbook.Worksheets For Each olQuery In olSheet.QueryTables If UCase$(Left$(olQuery.Connection, 8)) = "ODBC;LR:" Then olQuery.Connection = "ODBC;LR:" & slNewConnectionName ilTotalUpdated = ilTotalUpdated + 1 End If Next olQuery Next olSheet Call MsgBox("Updated " & ilTotalUpdated & IIf(ilTotalUpdated = 1, " query.", " queries."), vbInformation) End Sub