title: Call previously saved function VBA
body: <p>was wondering why I received an error "Compile Error- Argument Not Optional" When I run the following code? I'm a beginner at VBA. Basically, I want it to embed the previously defined function by calling it.</p>
  
  <pre><code> Function testranges(range1 As Range, range2 As Range)
      'function to compare if the values of two ranges are the same
      'define the variables
      Dim range1rows, range1cols, range2rows, range2cols, i, j As Integer
      ' count the rows and columns in each of the ranges
      range1rows = range1.Rows.Count
      range1cols = range1.Columns.Count
      range2rows = range2.Rows.Count
      range2cols = range2.Columns.Count
  
      'are the ranges the same dimension?
      testranges = (range1rows = range2rows And range1cols = range2cols)
  
      'if same dimension loop through the cells
      If (testranges) Then
  
          For i = 1 To range1rows
              For j = 1 To range1cols
  
              If (range1.Cells(i, j).Value &lt;&gt; range2.Cells(i, j).Value) Then
                  testranges = False
              End If
  
              Next
          Next
  
      End If
  
      'loop through
      'for
  End Function
  
  'Call previously defined fucntion
  Sub comparesheetnew()
      Call testranges
  
  End Sub
  </code></pre>