Of the pre-2004 EU 15 (one of which has now left), two had opt-outs, the UK and Denmark. Sweden did not. The other twelve have all adopted the Euro.
The 2004 expansion was ten countries, of which seven have adopted the Euro (Malta, Estonia, Latvia, Lithuania, Slovakia, Slovenia, Cyprus).
The 2007 and 2013 expansions included three countries, none of which have yet joined the Euro.
So of the 27 countries in the EU, 19 use the Euro, and eight do not.
Of those eight, one has a negotiated opt-out (Denmark). The UK did also, but they quit the whole project anyway.
Of the other seven, Sweden has been dodging the Euro since introduction (sometime between 1999 and 2002, depending on which event you count). Poland, Czechia, and Hungary have managed to avoid the Euro for 17 years now, Bulgaria and Romania for 14 years, and Croatia for eight years.
The requirement (absent a special opt-out or other arrangement) is that the Euro be adopted as soon as the country meets the requirements. The rather creative method Sweden has used is to make sure they don't meet the requirements, something which is possible to do. Whether the EU will decide to close that particular loophole in any subsequent enlargements, I do not know.
But under current arrangements, it seems quite possible to avoid the Euro for decades if you're really determined to do so.
If there is an independent Scotland in the future, we don't know whether it will be by a careful, well-planned and well-executed withdrawal from the UK, or something more chaotic (maybe more like the UK's withdrawal from the EU). If it's chaotic, I think the currency of an independent Scotland would be the British pound, at least for a year or two. If they execute it better, then there may be an independent Scottish currency from day one.
Note that when things are chaotic enough (and I certainly hope this doesn't happen to Scotland), the people decide what currency to use irrespective of what the government decides the "official" currency is - take Zimbabwe for example. When Russia was experiencing high inflation, some shops adopted the innovation of marking the prices in US dollars, even though you still paid in roubles. That way, they only had to update the exchange rate when the rouble had lost value, rather than going around the shop and remarking all of the prices.
In the POW camps during the war, they used cigarettes