You have created a variable to hold your array of data:
Dim LinkedUnits(,) As String
But you haven't allocated any data to it!
It's like taking a paper bag and passing it round to your friends - if you haven't put any sweets in the bag to start with, they are going to wonder what you are doing because they try to get a sweet and the bag is empty!
Try something like this:
Dim LinkedUnits(,) As String =
New String(dgUnits.Rows.Count, 2)