VBA Excel SQL Error "No Value Given for One or More Required Parameters"

SamDsouza

Board Regular
Joined
Apr 16, 2016
Messages
205
Hello
Code adopted from below URL
https://analystcave.com/excel-using-sql-in-vba-on-excel-data/

Getting syntax error as per the above heading
when following query executed

SELECT [Sheet1$].[First Last], [Age], [Salary] FROM [Sheet1$] INNER JOIN [Sheet2$] ON [Sheet1$].[First Last]=[Sheet2$].[First Last]

getting error "No Value Given for One or More Required Parameters"

Can someone help me to correct the syntax for above SQL query ?

As this the first time implementing with SQL query

Thanks
SamD
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi, Sam

IIRC, that error is when a field name in the query is not found in the data.

Suggest you carefully check field headers "First Last", "Age", and, "Salary" match between the worksheets & the SQL.
For example, a trailing space like "Age " on the worksheet would be the sort of thing that gives mis-match, and then the error.

Also, if your "Sheet2" has similar field names, best to explicitly reference the source table you want to select. That is,
SELECT [Sheet1$].[First Last], [Sheet1$].[Age], [Sheet1$].[Salary]

regards, Fazza
 
Upvote 0
Thanks Fazza really appreciate your guidance. :). BTW can you suggest website or URL where i can refer to maximum SQL syntaxes.
 
Upvote 0
Maximum. That is done like this,

Code:
SELECT MAX(some field), other fields you want
FROM table
GROUP BY other fields you want

Order of fields in SQL doesn't matter, btw.

If you want to filter,
Code:
SELECT MAX(some field), other fields
FROM table
WHERE something = 'this one'
GROUP BY other fields

And if you want to select based on the maxima,
Code:
SELECT MAX(some field), other fields
FROM table
WHERE something = 'this one'
GROUP BY other fields
HAVING MAX(some field) > 1000

PS. I have no specific site recommendations for SQL syntax
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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