title: Comparing 2 Numbers in VBA
body: <p>I'm trying to compare 2 3-digit numbers. This is my current code using nested Ifs</p>
  
  <pre><code>If Mid(Num1, 1, 1) = Mid(Num2, 1, 1) Then  
  'Check first number against first number
  
  If Mid(Num1, 2, 1) = Mid(Num2, 2, 1) Then 
   'Check second number against second number
  
  
     If Mid(Num1, 3, 1) = Mid(Num2, 3, 1) Then  
      'Check third number against third number 
  
          Digits = 3
  
      Else
  
          Digits = 2
  
      End If
  </code></pre>
  
  <p>And this is just one small part of it. Also, I need to check the order in which they match as well. So whether it's an exact match, all 3 digits match in any order, or if 1 or 2 digits match in any order.</p>
  
  <p>The problem is I have a lot of If statements using this method as I have to compare every combination of digits to check for a 1 digit, 2 digit, 3 digit, etc, match. Is there a better way?</p>