Using SQL in Excel to Select from Cell value

I am using some sql in a module in my Excel file and need to know if I need to Select a value from a cell in Sheet if that is possible using SQL?

Set RST = New ADODB.Recordset
                           
 SQL = "SELECT  [Business Group Code], [Business Unit Code] FROM [AllData]"
 
RST.Open SQL, cn, adOpenStatic
Medicine1Asked:
Who is Participating?
 
Brad Sims, CCNANetwork AdministratorCommented:
Can you attach an example file so I can see exactly what you are looking for?  If you need to select a value from a cell it would seem easier to have VBA pull the value rather than writing a SQL query unless I'm misunderstanding the question.
0
 
MakriniCommented:
You can do.  The trick is to have headers in the sheet - or have a named range...  then you can SQL query it as you would any other database table.

  Easiest way to see the syntax is to create a querytable using the wizard - and then use

?Activecell.querytable.sql

in your immediate window to get used to Excels table names and such.  Once you are used to that - yes you can just code your queries with SQL.

 
0
 
Medicine1Author Commented:
John15-16  = the example would be

A                                        B
Business Group              XYZ
Business Unit                 ABC
Business Org                  DCD      

I understand the named ranged piece for having a table, but these will be row headings and that is why I am asking.  Can it be done with row headings?  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.