Parameter with multiple values SQL

Beanie18

New Member
Joined
Feb 9, 2022
Messages
2
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Does anyone know if it's possible to have a parameter with multiple values in a SQL query? I am working on excel with a recordset and the parameter is in the cell B4, but I would like to give the user the option to add more than one value as a filter, using then a comma to separate the values. For example, looking for all suppliers in a four different cities. Does anyone have any ideas? Thank you so much.

VBA Code:
Dim originCity As String
originCity = Sheet1.Range("B4")
   
Dim SuppliersQ As String
SuppliersQ  = "Select [ID], [Company], [Dept], [City], [Contact Person], [Phone] From [Suppliers$] " & _
"Where ('" & originCity & "' is null or '" & originCity & "' = '' or [City]='" & originCity & "')"
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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