title: Put range into an array for more efficient loops
body: <p>I have a bunch of loops in a function and they loop over an array that I defined as a dynamic range. Below is some pseudocode of what I want to achieve</p>
  
  <pre><code>Dim myArray As Range
  myArray(x, j) 'So the array loops through each column and then each row in that column
  For i = 1 to lastRow
  If myArray(x, j).Value = myArray(x, i).Value Then
  'Do something
  </code></pre>
  
  <p>I have a bunch of these loops and it's super slow with datasets of 100+ rows. Basically everywhere where I have myArray defined as a Range, I want to change it to a Variant so I can a) loop over the array and b) use the array to check if values are the same instead of checking the range against a range, which is probably the root cause of the performance issues when there are 200 rows * 500 columns</p>
  
  <p><strong>Edit</strong></p>
  
  <p>How can I convert a dynamically defined range into an array?</p>
  
  <p>Do I need to do something like this?</p>
  
  <pre><code>lastRow = UBound(myArray, 1)
  lastColumn = UBound(myArray, 2)
  </code></pre>
  
  <p>And then</p>
  
  <pre><code>If myArray(x, j) = myArray(x, i) Then
  'Do something
  </code></pre>