I created a connection in Excel using SQL query, and I have a dynamic query in my Excel cell. This will be dynamic and will be updated based on the slicer options I created.
I want to run the query based on the dynamic query refers from Excel cell.
Below is the VBA code to refer the query and refresh the connection to run.
I get
run-time error "Application-defined or object-defined error"
The code runs till the line "Sheet1.Select", but it throws error while executing the yellow highlighted line.
CodeString = picks the updated query from Sheet2.Range("A1")
Below is the code from Sheet2, this is dynamic, will be changed as required.