blacktusk
05-11-2009, 11:26 PM
I expect this is a simple question;
I am attempting to pass a set of parameters to a SQL query, using values stored in known worksheet cell names. In this example I have stored a table name in the cell TableName.
However, when I use the syntax below, my tableName variable returns a cell reference of the form;
"=worksheet!$row$col", eg. "=control!$B$2"
Private Sub CommandButton2_Click()
Dim tableName As String
tableName = ActiveWorkbook.Names("TableName").Value
SQLDataTableExtract (tableName)
End Sub
I want the contents of the cell, which should be "Products", not the reference.
How can I convert the cell reference into a value using VBA, so that I can pass it to the query function??
I am attempting to pass a set of parameters to a SQL query, using values stored in known worksheet cell names. In this example I have stored a table name in the cell TableName.
However, when I use the syntax below, my tableName variable returns a cell reference of the form;
"=worksheet!$row$col", eg. "=control!$B$2"
Private Sub CommandButton2_Click()
Dim tableName As String
tableName = ActiveWorkbook.Names("TableName").Value
SQLDataTableExtract (tableName)
End Sub
I want the contents of the cell, which should be "Products", not the reference.
How can I convert the cell reference into a value using VBA, so that I can pass it to the query function??