Basically Shopify has no options to exclude products from Discount Codes.
BUT
you can select a collection on which the discount code should apply to.
By using our app, you can create those collections dynamically adjusting without worrying about it anymore.
This guide explains how to prevent your sale products from being combined with Discount Codes to avoid unwanted double reductions.
When now running your sale campaign your selected products will automatically be excluded from the collection „not-on-sale“ you created before and therefore cannot be further discounted with Discount Codes.
After the sale ends the tag „not-on-sale" will be automatically added to this collection again and Discount Codes will work for these products.