Generally you use a RNGMERGE() formula to combine the numbers from a non-contiguous set of departments. Assuming $B9 contains your account ranges (with a training "-") separated by commas, and $C$5 contains your list of departments separated by commas, the formula would be:
=-ADGET("gldata.M",RNGMERGE($B9,$C$5))
This creates all the possible account-department pairs from the two comma separated lists.