Excel Query to Exclude a Condition but if left blank would return all Condition's

DennisYoung

New Member
Joined
Jun 27, 2022
Messages
14
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
I am trying to Add a Query to my table to Exclude a Condition that would be set by a Parameter setting pointing to a cell.

I know how to add the Condition field to the Query (SH2.jpg) but I do not know what to use as the value so the parameter would look at the cell and exclude the value in the cell and return all other values to include blank values and if the value is left blank to return all values.

I have the reference cell set up (SH4.jpg)

I have tried <>"*", <>[], <>?, <>[?] and other combinations but none have worked

Any help would be appreciated.
 

Attachments

  • SH2.jpg
    SH2.jpg
    43.9 KB · Views: 7
  • SH4.jpg
    SH4.jpg
    21.2 KB · Views: 7

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Never had a question go unanswered before.

I did figure out how to do this though.

In the MSQuery I added Criteria field of Condition then in the value put in <>[Parameter4} then under or I put is Null then added a second [Yard#] and Between [SD] and [ED]

And it made a parameter for me that I pointed to the reference cell I wanted to exclude

And on a refresh all worked perfectly

I added a total of 5 Parameter fields like this (see screenshot SH5.jpg) and pointed those Paramters (see screen shot SH6.jpg) to separate reference fields (see screen shot SH7.jpg)

And I can exclude one or multiple Conditions this way
 

Attachments

  • SH5.jpg
    SH5.jpg
    33.2 KB · Views: 7
  • SH6.jpg
    SH6.jpg
    31.4 KB · Views: 7
  • SH7.jpg
    SH7.jpg
    30.9 KB · Views: 7
Upvote 0
Solution

Forum statistics

Threads
1,216,174
Messages
6,129,297
Members
449,499
Latest member
HockeyBoi

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