Hi
I'm looking to pass a value from a cell into a VBA query but unsure of the format.
See below code as an example, in the working version of this code, the 3rd line has a specific value for the name of the WorkbookConnection, eg;
With ActiveWorkbook.Connections("MyDataConnection")
What I'm trying to do is use the value in cell B12 instead of MyDataConnection
Appreciate any help!
Thanks
PrivateSub Button_get_wkbook_conn_info_Click()
Dim WorkbookConnectionName As Range
Set WorkbookConnectionName =Worksheets("Lists").Range("B12").Value
With ActiveWorkbook.Connections("& WorkbookConnectionName & ")
Worksheets("Lists").Range("B2").Value = .Name 'Workbook Connection Name
End With
End Sub
I'm looking to pass a value from a cell into a VBA query but unsure of the format.
See below code as an example, in the working version of this code, the 3rd line has a specific value for the name of the WorkbookConnection, eg;
With ActiveWorkbook.Connections("MyDataConnection")
What I'm trying to do is use the value in cell B12 instead of MyDataConnection
Appreciate any help!
Thanks
PrivateSub Button_get_wkbook_conn_info_Click()
Dim WorkbookConnectionName As Range
Set WorkbookConnectionName =Worksheets("Lists").Range("B12").Value
With ActiveWorkbook.Connections("& WorkbookConnectionName & ")
Worksheets("Lists").Range("B2").Value = .Name 'Workbook Connection Name
End With
End Sub