Thanks guys! Both of your solutions worked, but @Gribouillis's solution fits my needs better.
(Also unrelated question, but does this site have a method of marking threads solved or anything, by any chance?)
(Also unrelated question, but does this site have a method of marking threads solved or anything, by any chance?)