You can use CommandStats to obtain the number of items in the inventory as a scoreboard value, without being restricted to a single slot.

Prerequisites:

Objectives to hold the value.

/scoreboard objectives add StickCount dummy
/scoreboard objectives add IronCount dummy

In order for CommandStats to modify a score, the target must be tracked prior. This may need to run on a clock in the event new players can join at any time.

/scoreboard players add @a StickCount 0
/scoreboard players add @a IronCount 0

Detection:

The following must be run in numerical order on a clock.

  1. Apply the necessary AffectedItems trigger such that the player modifies their StickCount score.

    /stats entity @a set AffectedItems @a[c=1] StickCount
    
  2. Cause players to run a /clear command, targeting themselves. While it does not remove any item, this causes their StickCount score to be set equal to the items that could have been cleared, which is equal to the number of sticks they had.

    /execute @a ~ ~ ~ clear @a[c=1] minecraft:stick 0 0
    
  3. For other items, you repeat #1 and #2.

    /stats entity @a set AffectedItems @a[c=1] IronCount
    /execute @a ~ ~ ~ clear @a[c=1] minecraft:iron_ingot 0 0
    
  4. You can then run commands targeting players based on their score. For example, the following says the name of players who had 2 or more sticks and iron ingots anywhere in their inventory (including spread across 2 separate stacks).

    /say @a[score_StickCount_min=2,score_IronCount_min=2] had 2 or more sticks & iron ingots.