Query Table - Using a Cell Value

clumzyfish

New Member
Joined
Oct 6, 2009
Messages
29
Hi All,

I have a Query Table and would like to update the address used for the query, based on a cell value. Is this possible?

Here is my current VBA:

Code:
Sub Test()
'
' Test Macro
'

'
Application.ScreenUpdating = False
    Range("A4").Select
        Sheets("Data").Visible = True
    Sheets("Data").Select
    Range("A44").Select
    With Selection.ListObject.QueryTable
        .Connection = _
        "OLEDB;Provider=Microsoft.Office.List.OLEDB.2.0;Data Source="""";ApplicationName=Excel;Version=12.0.0.0"
        .CommandText = Array( _
        "<LIST><VIEWGUID>{23EE30A3-74DD-4FBE-8353-511EABD13B75}</VIEWGUID><LISTNAME>{D6D57BC4-E093-4F65-A273-0A8D72EA8B44}</" _
        , _
        "LISTNAME><LISTWEB>Insert real web address here</LISTWEB><LISTSUBWEB></LISTSUBWEB>" _
        , "<ROOTFOLDER>Insert real root folder here</ROOTFOLDER></LIST>")
        .Refresh BackgroundQuery:=False
    End With
    Sheets("Data").Select
    ActiveWindow.SelectedSheets.Visible = False
    Sheets("Test Results").Select
Application.ScreenUpdating = True
End Sub

I guess I'm looking to change the .CommandText to display cell value A1 (which will have the replacement query or array, whichever can be done), if that's possible

Thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

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