VBA SQL Query from Cell

LePig

New Member
Joined
Aug 30, 2016
Messages
16
Hi I am trying to get data from a cell and need a little help.

Code:
sSQLSting = "SELECT * From (" & Sheets(SpreadsheetName).Cells(firstAddress, Colname + 2) & ")"

This is returning nothing?

Any help would be appreciated.
 
This code is being run on a commandbutton on a userform - excel vba
 
Last edited:
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you are using Excel VBA, I do not understand why you would want to involve SQL code at all.
What is the relation of the data you are trying to extract from the Excel file that the userform and code is stored in.
Is it the same?
If not, how does the SQL code know where to look to find this file?
 
Upvote 0
The best approach is for me to use a database I just need a little help. Nevermind - i shall work it out.
 
Upvote 0
We are trying to help you, but we are trying to understand your whole structure here. You really haven't provided very much details as to how all of this is laid out, and how everything is connected.
 
Upvote 0
Upvote 0
to reference a worksheet named "whatever" use this syntax

SELECT field names
FROM [whatever$]
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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