Try something like this (using Daniel's suggestion):
nearestIndex[list_, a_] := Nearest[list -> Range[Length[list]], a][[1]]; {pos5 -> nearestIndex[m5, a], pos6 -> nearestIndex[m6, a]}
To get the position(s) you can use Nearest[values->Range[Length[values], a]. That should allow you to avoid Position. No idea why Flatten is needed without seeing your actual example.
If you could edit your posting to include a small example with all the data, what the solution should be and why then it might be more likely that you would get good answers more quickly.