The yarn label has a dye lot number, so if you are buying 8 skeins of yarn you want to make sure that the dye lot number is all the same. But the dye lot number is different than the color number. That number is just a number assigned by the manufacturer for that color. So look carefully at the label.
I just had a very good example of varying dye lots. I decided to use up some lambs pride worsted I had to make mittens. Got one mitten done, looked at my remaining yarn and thought, uh oh! So I weighed the finished mitten and then weighed the yarn, I was 15 grams short. But oh well, they are just mittens, they are worn on different hands, they are for me, I don’t have to be exactly perfect. I oringinally purchased this yarn several months ago. So went to the LYS and looked at the color and thought, that looks good, but in my light at home it was quite off, a shade darker and more grey fibers in it. The color is kiwi. So anyway, I ended up alternating the old yarn with the new yarn as I knitted so the mitten wouldn’t look too much darker than the other, I ended up with a subtle, shadowy stripe which in itself looks rather cool, but it doesn’t exactly match the opposite mitten. Whatever, they are for me after all. The down side is now I have more green yarn to use up, so much for clearing the stash.