This Variation brings all the selections to the beginning of the array, so the logic is more straightforward. The body of the program only executes if the number of picks is lower or equal to the selection range, and will only display the numbers not selected if fewer than the range were indeed picked.
range = 40 'entire range
picks = 10 'number of selections
DIM picks AS INTEGER, range AS INTEGER, first AS INTEGER
DIM index AS INTEGER, x AS INTEGER
DIM numbers(range) AS INTEGER
IF picks <= range THEN 'proceed only when we are picking fewer
'or equal times to what the range allows
FOR x = 1 TO range 'assign sequential values to array
numbers(x) = x
PRINT "Partial Shuffle Sort:"
FOR x = 1 TO picks 'only shuffles up to the number of selections
index = INT(RND * (range)) + x 'random index up to diminished range
PRINT TAB(10); numbers(index), "goes to position:"; x
SWAP numbers(index), numbers(x) 'swaps value with beginning of diminished range
range = range - 1
PRINT : PRINT "Numbers selected, in sequence:"
FOR x = 1 TO picks
IF picks < 40 THEN
PRINT : PRINT
PRINT "Numbers not selected:"
FOR x = picks + 1 TO range